我的代码是:
public class try1 {
public static void main(String[] arg){
System.out.print("in main\n");
try{
ablurt( "An exception will occur" );
}
catch( Exception e )
{
System.out.print("exception occured--"+e);
}
finally{
System.out.print("I'm always here");
}
}
}
我的问题是,如果我尝试使用netbeans IDE运行此代码,则会创建类文件并导致运行时错误。
但是如果我尝试在cmd上运行它,那就是编译时错误,并且也没有创建类文件
为什么同一个程序的行为不同?
答案 0 :(得分:2)
我不知道Netbeans,但是带有编译错误的源文件的Eclipse does实际上是编译了一个抛出Error
的类的修改版本。我认为这也是Netbeans所做的。