public class simple {
public static void main(String[] args) {
try {
System.out.print("hello ");
throwit();
} catch (Exception re) {
System.out.print("caught ");
}
}
public static void throwit(){ // line number 11
throw new Exception(); // line number 12
}
}
为什么它给我一个编号错误行号12。 如果我使用抛出异常行号11然后它工作正常。 如果我抛出异常的子类(在行号12),那么它工作正常...为什么这样?...为什么我不能在try catch语句中调用的方法中抛出Exception(checked)?
我想知道实际发生了什么后面(如何编译器显示此错误)?
如果throwit抛出检查异常,需要声明的是,不管是什么代码调用throwit。 – MatrixFrog 2011-04-29 06:06:00