【发布时间】:2013-04-04 07:53:49
【问题描述】:
如果我在 catch 块中写 RunTimeException 那么为什么它没有被处理。
class main{
public static void main(String cs[]){
try{
int a = 10/0;
}
catch(RunTimeException e){
System.out.println("exception caught");
}
}
}
我的问题是为什么如果我编写 RunTimeException 会出现错误,而不是如果我编写 RunTimeException 的子类,即 ArithmaticException 和超类 Exception。
错误是
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
RunTimeException cannot be resolved to a type
【问题讨论】:
-
尝试使用一个像样的Java IDE,你就不会遇到这些问题了。
标签: java exception exception-handling core