在构造函数中进行异常处理引起的问题 那你就在super(name,age);语句后面加上检查语句不就行了吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public Student(String name,int age,long stuid)throws ...{super(name,age);this.stuid = stuid}再抛出去,不能让子类把异常给吃了 public Student(String name,int age,long stuid) throws IllegalArgumentException{ super(name,age); if(age>100 || age<0) throws new IllegalArgumentException("年龄值异常:" + age); this.stuid = stuid;} 你可以把父类的构造函数改造一下: public Person(String name,int age){ if (age>1 && age<100) { this.name = name; this.age = age; } else{} } 求高手用多线程实现文件归类,单线程的我已经写好了 这个程序为什么不能运行? 请教各位,字符串识别问题,从一个字符串中提取去掉逗号的内容。 二维数组问题 Java与Windows API 这里用eclipse的人多吗,求资源 请教JDBC连接sql server2000ResultSet 不支持first,last,previous怎么办?非常感谢! java -d 命令行后接什么参数? 串口开发包JAVAX.COMM的配置问题 关于字符串常量池实在有个地方想不明白,求大神指点! 请问个位前辈 谁有比较高的版本的java Doc?可以搜索的那种
super(name,age);
this.stuid = stuid
}
再抛出去,不能让子类把异常给吃了
super(name,age);
if(age>100 || age<0) throws new IllegalArgumentException("年龄值异常:" + age);
this.stuid = stuid;
}
public Person(String name,int age){
if (age>1 && age<100)
{
this.name = name;
this.age = age;
}
else{}
}