以下是「throw use;」顯示錯誤的代碼。爲什麼?如何爲用戶定義的異常使用throw?舉一些例子?對用戶定義的異常使用throw
class use extends Exception{
public String toString() {
return "too many exceptions";
}
}
class user{
public static void main(String s[]) {
int i=3;
try {
if(i>1)
throw use;
}
catch(use e) {
System.out.println(e.toString());
}
finally{
System.out.println("program executed successfully!");
}
}
}
它顯示了什麼錯誤? –