投げるよ投げるんだよ投げちゃうからね

(1/8微妙に追記)
メソッドのthrowsに同じ例外を複数書いていいと知った。
これでもかとExceptionを投げると宣言することができる。
これで共同開発者に例外への思い入れを伝えよう!

public class ThrowsTest3 {
	public int throwmany() throws Exception, Exception, Exception {
		return 3;
	}
}

さらにサブクラスでは増やすことも減らすこともできる。
ただしスーパークラスで宣言されている例外のサブクラスでなければ投げられない。

public class ThrowsTest4 extends ThrowsTest3 {
	@Override
	public int throwmany() throws Exception, Exception, Exception, Exception {
		return 4;
	}
}

class ThrowsTest0 extends ThrowsTest3 {
	@Override
	public int throwmany() {
		return 0;
	}
}

class ThrowsThrowable extends ThrowsTest3 {
	//error
//	@Override
//	public int throwmany() throws Throwable {
//		return super.throwmany();
//	}
}