class Person
{
private String name;
private int age;
Person()
{
System.out.println("A:name="+name+" age="+age);
}
Person(String n)
{
name = n;
System.out.println("B"+"name="+name+" age="+age);
}
public void setName(String n)
{
name = n;
}
public String getName()
{
return name;
}
Person(String n,int a)
{ name = n;
age = a;
System.out.println("C"+"name="+name+" age="+age);
}
public void cry()
{
System.out.println("cry......");
}
}
class PersonDemo2
{
public static void main(String[] args)
{
//Person p1 = new Person();
//p1.cry();
Person p2 = new Person("lisi");
p2.setName("libushi");
System.out.println(p2.getName());
}
}
求问getName是怎么执行的,或许该程序只是用到了设置值,没用到getName获取值。但是我想知道,getName是怎么执行的,他是怎么获取值的,请教执行流程?
|