[Java] 纯文本查看 复制代码 class MyException extends Exception
{
MyException(){}
MyException(String msg)
{
super(msg);
}
}
class LeaveMeAlone
{
private int a=0;
void show()throws MyException
{
if(a==0)
throw new MyException("java不想理你,并向你抛出一个MyException");
}
}
class Demo
{
public static void main(String[] args)
{
LeaveMeAlone l=new LeaveMeAlone();
try
{
l.show();
}
catch (MyException e)
{
System.out.println(e);
}
}
} |