例外

何の役に立つかわからないけど気になったからやってみたらできた。

public class Main {
	public static void main(String[] args) {
		throw e();
	}

	private static RuntimeException e() {
		return new RuntimeException();
	}
}

とりあえず例外投げたいけど何投げるかは引数によって変えるとかできるかもしれないけど何かダメな気がする。

public class Main {
	public static void main(String[] args) {
		throw e(args.length);
	}

	private static RuntimeException e(int i) {
		switch (i) {
		case 0:
			return new UnsupportedOperationException();
		case 1:
			return new IndexOutOfBoundsException();
		case 2:
			return new IllegalStateException();
		default:
			return new RuntimeException();
		}
	}
}

何これ気持ち悪い。