在自定义类继承Exception后,为什么还是说找不到这个类package roy;class FuShuIndexException extends Exception
{
FuShuIndexException()
{}
FuShuIndexException(String msg)
{
super(msg);
}
}
class Free
{
public int method(int[] arr,int index)throws NullPointerException//,FuShuIndexException
{
if(arr==null)
throw new NullPointerException("没有任何数组实体");
if(index<0)
throw new FuShuIndexException();

return arr[index];
}
}class  ExceptionDemo4
{
public static void main(String[] args)
{
int[] arr = new int[3];
Free d = new Free();
try
{
int num = d.method(null,-1);
System.out.println("num="+num);

}

catch(NullPointerException e)
{
System.out.println(e.toString());
}
catch (FuShuIndexException e)
{
System.out.println("message:"+e.getMessage());
System.out.println("string:"+e.toString()); e.printStackTrace();//jvm默认的异常处理机制就是调用异常对象的这个方法。 System.out.println("负数角标异常!!!!");
}

/*
catch(Exception e)//多catch父类的catch放在最下面。
{

}
*/
System.out.println("over");
}

}