本帖最后由 完美恋爱 于 2013-11-27 20:18 编辑
class FuShuException extends Exception
{
FuShuException()
{
super();
}
FuShuException(String message)
{
super(message);
}
}
class Chu
{
int chu(int a, int b)throws Exception,FuShuException
{
if(b < 0)
throw new FuShuException("被除数为零啦!");
return a/b;
}
}
class Demo
{
public static void main(String[] args)
{
Chu c = new Chu();
try
{
int num = c.chu(3,-1);
System.out.println("num = "+num);
}
catch(Exception e)
{
}
catch(FuShuException e)
{
System.out.println(e.toString());
}
}
}
这段代码哪里写错啦?为什么错误提示是:已捕捉到异常 FuShuException
|