public class ReturnExceptionTest
{
public static void main(String[] args)
{
ReturnExceptionTest t = new ReturnExceptionTest();
System.out.println("调用t.divide(2)方法返回结果:"+t.divide(2));
}
public int divide(int i){
int y =10;
try
{
System.out.println("y="+y+"i="+i);
int a = y/i;
return a;
}
catch (ArithmeticException e)
{
System.out.println("捕获ArithmeticException异常");
e.printStackTrace();
}
finally{
System.out.println("这是finally语句");
}
System.out.println("the programe is end");
return y;
}
}
上面的try...catch...finally代码编译后报出下面的错误,这个错误是什么意思,代码哪里错了???
/*
Exception.java:1: 错误: 类ReturnExceptionTest是公共的, 应在名为 ReturnExceptionT
est.java 的文件中声明
public class ReturnExceptionTest
^
1 个错误
*/ 代码哪里错了??? |