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=(40);//总是提示这里找不到符号,请问怎么改?
p.speak();
}
} |
|