/*下面做了归纳总结,欢迎批评指正*/
/*自定义异常*/
class ChushulingException extends Exception
{
public ChushulingException(String msg)
{
super(msg);
}
}
class ChushufuException extends Exception
{
public ChushufuException(String msg)
{
super(msg);
}
}
/*自定义异常 End*/
class Numbertest
{
public int shang(int x,int y) throws ChushulingException,ChushufuException
{
if(y<0)
{
throw new ChushufuException("您输入的是"+y+",规定除数不能为负数!");//抛出异常
}
if(y==0)
{
throw new ChushulingException("您输入的是"+y+",除数不能为0!");
}
int m=x/y;
return m;
}
}