本帖最后由 惠晖 于 2012-11-1 13:52 编辑
class Person
{
private int age;
public void setAge(int a)
{
if (a>0 && a<130)
{
age=a;
speak();
}
else
System.out.println("feifaage");
}
public int getAge()
{
return age ;
}
public void speak()
{
System.out.println(age);
}
}
class PersonDemo
{
public static void main(String []args)
{
Person p =new Person();
p.setAge(20);
}
} |
|