本帖最后由 姿_`态 于 2014-6-17 18:16 编辑
class ExceptionDemo1
{
public static void main(String[] args)// throws Exception
{
Demo d =new Demo();
try
{
int i=d.div(4,1);
System.out.println(i);
}
catch (Exception e)
{
//e.printStackTrace();
//System.out.println(e.toString());
System.out.println(e.getMessage());
}
System.out.println("over");
}
}
class Demo
{
int div(int a,int b)throws Exception
{
int[] arr = new int[a];
System.out.println(arr[10]);
return a/b;
}
}
为什么输出时 :
10
over
|