作者在 2008-02-10 10:22:54 发布以下内容
class Person
{
private int age;
public void setAge(int i)
{
if(i<0||i>130)
return;
age=i;
}
public int getAge()
{
return age;
}
}
public class TestPerson
{
public static void main(String args[])
{
Person p1=new Person();
p1.setAge(3);
p1.setAge(-6);
System.out.println(p1.getAge());
}
}
{
private int age;
public void setAge(int i)
{
if(i<0||i>130)
return;
age=i;
}
public int getAge()
{
return age;
}
}
public class TestPerson
{
public static void main(String args[])
{
Person p1=new Person();
p1.setAge(3);
p1.setAge(-6);
System.out.println(p1.getAge());
}
}