package com.review;/*当方法的局部变量和另类的成员变量重复的时候根据就近原则优先使用成员变量如果需要访问本类中的成员变量,需要使用格式this.成员变量名一定 在方法中使用 通过谁调用谁就是this. */public class thisPerson { String name; public void sayhello(String name){ System.out.println(name+"我是"+this.name); System.out.println(this);//com.review.thisPerson@154617c this和Person地址值一样证明了通过谁调用谁就是this } public static void main(String[] args) { thisPerson Person = new thisPerson(); Person.sayhello("王小尹");//王小尹我是null System.out.println(Person);//com.review.thisPerson@154617c }}
来源:https://www.cnblogs.com/xzwx668/p/12046168.html