以下是代码:
class personDemo
{
private String name;
private int age;
person(String n)
{
name = n;
System.out.println("B:name="+name+",age="+age);
}
public void setName(String n)
{
name = n;
}
}
class personDemo2
{
public static void main(String[] args)
{
person p = new person("lisi");
p.setName("zhangsan");
System.out.println(p.getName());