本帖最后由 起风了956 于 2018-4-4 13:21 编辑
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(4,0);
System.out.println("x="+x);
}
catch (Exception e)
{
System.out.println("除零了");
}
}
}C:\Users\dell\Desktop |
|