任何人都可以解释为什么下面的代码正在处理私有成员变量?
public class Person implements Comparable<Person> {
private String firstName;
public Person(String firstName) {
this.firstName = firstName;
}
@Override
public int compareTo(Person o) {
return firstName.compareToIgnoreCase(o.firstName); // why does it work? } }
}
}
Run Code Online (Sandbox Code Playgroud)
编辑为什么o.firstName要编译?其中firstName是private可变的.