class FuShuException extends Exception{
private String msq;
FuShuException(String msq){
this.msq=msq;
}
public String getMessage(){
return msq;
}
}
class Demo{
int div(int a,int b)throws FuShuException
{
if(b<0)
throw new FuShuException();
return a/b;
}
}
class Exceptiondemo11{
public static void main(String[]args)
{
Demo d=new Demo();
try{
int x=d.div(4,-1);
System.out.println("x="+x);
}
catch (FuShuException e){
System.out.println(e.toString());
}}}
|
|