-2
我有一些問題,試圖使我整個班級唯一的共同例外。有人能告訴我如何做到這一點?在此之前,我試圖讓小試擲-catch塊這樣的:整個班級的例外
try {
Integer a = 10;
if(a == 10)
throw(/*what to write here?*/)
}
//some code later... or here must be NO code because catch goes right after the try(if I'm not mistaken)?
catch(/*what to write here?*/){
System.err.println("smth gone wrong");
}
所以,問題是如何建立一個大的例外全班同學,以及如何使上述正確的例子嗎?