class OutBoundsException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
OutBoundsException(String mes){
super(mes);
}
}
class Check{
String ChecktheNum(int n) throws OutBoundsException{
Integer N=new Integer(n);
if(n>30||n<20)
throw new OutBoundsException("the number is out of bound!!");
else
return "the number"+N.toString()+"is in the bounds";
}
}
class Test {
public static void main(String args[]) {
Check c=new Check();
try{
System.out.println("以下是合法的数据报告:");
System.out.println(c.ChecktheNum(25));
System.out.println("以下是非法的数据报告:");
System.out.println(c.ChecktheNum(5));
}catch(OutBoundsException e){
System.out.println(e.toString());
}
}
}
return "the number"+N.toString()+"is in the bounds";中的N.toString()怎么解释 ??
还有下面的 System.out.println(e.toString());是什么意思啊 为什么是e.toString()而不是c.toString()????
急啊 !!!谢谢大虾们了