class Demo
{
int div(int a,int b)
{
return a/b;
}
}
class ExceptionDemo
{
public static void main(String[] args)
{
Demo d=new Demo();
try
{
int x=d.div(8,0);
System.out.println("x="+x);
}
catch (ArithmeticException e)
{
System.out.println("完毕.");
}
catch (Exception e)
{
System.out.println("处理完毕.");
}
System.out.println("程序结束。");
}
} |
|