class FuShuException extends Exception
{}
class Demo
{
int div(int x,int y)throws FuShuException
{
if(y<0)
throw new FuShuException();
return x/y;
}
}
class ExceptionDemo
{
public static void main(String[] args)
{
Demo d=new Demo();
try
{
int x=d.div(4,-1);
System.out.println("x:"+x);
}
catch(FuShuException f)
{
System.out.println(f.toString());
}
System.out.println("over");
}
}
问题就是:
红色的那两句代码如何理解呢,我的理解是catch(FuShuException f)就相当于FuShuException f=new FuShuException,不知道这样理解行不. |