验证中...
语言: Java
分类: 编程语言基础
最后更新于 2018-04-16 23:01
Test.java
原始数据 复制代码
public class Test {
public static void main(String[] args) {
Students S = new Students();
try {
S.setAge(10);
} catch (AgeNotFu ag) {
System.out.println(ag.getMessage());
}
}
}
class Students {
int age;
public void setAge(int age) {
if (age < 0) {
throw new AgeNotFu("䲻Ϊ");
}
this.age = age;
System.out.println("óɹ");
}
}
class AgeNotFu extends RuntimeException {
AgeNotFu(String message) {
super(message);
}
}

评论列表( 0 )

你可以在登录后,发表评论

8_float_left_people 8_float_left_close