package ctgu.java;
public class TestPerson {
public static void main(String[] args) {
Person p = new Person();
p.steAge(120);
//p.steAge(150);
System.out.println(p.getAge());
}
}
class Person{
private int age ;
public int getAge(){
return age ;
}
public void steAge(int a){
if(a > 0&& a <=130){
age = a;
}else{
//System.out.println("你输入的数据有误");
throw new RuntimeException("你输入的数据有误!");
}
}
}
转载于:https://blog.51cto.com/9815936/1604899