本帖最后由 张向辉 于 2013-2-2 12:06 编辑
class Person
{
private int age;
public void setAge(int a)
{
if(a>0 && a<130)
{
age = a;
speak();
}
else
System.out.println("feifa age");
}
public int getAge()
{
return age;
}
void speak()
{
System.out.println("age="+age);
}
}
class PersonDemo
{
public static void main(String[] args)
{
Person p = new Person();
p.setAge =(20);
//p.speak();
}
}
}
|
|