package Java.bilibili.Demo01;
/**this关键字
* 当方法的局部变量和类的成员变量重名的时候 根据就近原则 优先考虑局部变量
* 如果需要访问本类当中的成员变量 需要使用格式:this.成员变量名
* ”通过谁调用的方法,谁就是this.“
* */
public class thisPerson {
public static void main(String[] args) {
Test test=new Test();
test.name="熊大";
test.sayHello("熊二");
System.out.println(test);//地址值
}
}
class Test{
String name;//我自己的名字
//who是对方的名字 成员变量name是自己的名字
public void sayHello(String name){
System.out.println(name+",你好。我是"+this.name);
System.out.println(this);
}
}