class FuShuException extends Exception
{
private int value;
FuShuException(String msg,int value)
{
super(msg)
this.value = value;
}
public int getValue()
{
return value;
}
}
class Demo
{
int div(int a ,int b)throws FuShuException
{
if (b<0)
throw new FuShuExceotion("出现了除数是负数的情况",b);//这段代码是如何加载?求指导
return a/b;
}
}
class ExceptionDemo3
{
public static void main(String[] args)
{
Demo d = new Demo();
try
{
int x = div(4,-3);
}
catch (FuShuException e)
{
e.printStackTrace();
System.out.println("除数出现了负数");
System.out.println("出现错误的数字"+b);
}
}
} |
|