this表示当前对象,所谓当前对象是指调用类中方法或属性的那个对象
public void setName(String name){
this.name=name
}
局部变量和成员变量同名时
局部变量会覆盖成员变量
this();写在第一行调用类的无参构造方法
public People{
System.out.Println("------");
}
public People(String name){
this();
this.name=name;
}
this表示当前对象,所谓当前对象是指调用类中方法或属性的那个对象
public void setName(String name){
this.name=name
}
局部变量和成员变量同名时
局部变量会覆盖成员变量
this();写在第一行调用类的无参构造方法
public People{
System.out.Println("------");
}
public People(String name){
this();
this.name=name;
}