本帖最后由 NewOnce` 于 2014-3-26 10:28 编辑
class Demo
{
int div(int a,int b)throw Exception
{
return a/b;
}
}
class ExceptionDemo1
{
public static void main(String[] args)
{
Demo d= new Demo();
try
{
int x=d.div(4,0);
System.out.println("x="+x);
}
catch (Exception e)
{
System.out.println("除零了"+e.toString());
}
System.out.println("Over");
}
}
|
|