以下是“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!");
}
}
}
它显示了什么错误? –