package Test;
/*
* Used to distinguish member variables and local variables with the same name;
* Who is calling the member, this represents who;
* When a member in a class is private, it can be obtained by the set and get methods.
*/
public class This {
public static void main(String[] args) {
Person p=new Person();
p.setName("kobe");
System.out.println(p.getName());
}
}
class Person{
private String name;//Because it is private, it cannot be accessed directly with p.name="kobe";
private int age;
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
}