O'Reilly logo
  • You Wang thinks this is interesting:

This method accesses the private fields of harry, which is not surprising. It also accesses the private fields of boss. This is legal because boss is an object of type Employee, and a method of the Employee class is permitted to access the private fields of any object of type Employee.


Cover of Core Java® Volume I—Fundamentals, Tenth Edition


If access privilege is not class-based, then it's impossible to compare two objects of the same class, because there is no way to compare the content of them.