So I was making a class the other day and used Eclipse\'s method to create the equals method when I realized that it generated the following working code:>
It's accessible from different instances of the same class.
According to this page (bolding mine):
At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. The private modifier specifies that the member can only be accessed in its own class.
For clarity I'll rewrite this line:
if ( t.privateInt == this.privateInt )
We can agree that "this.privateInt" should be allowed: you are accessing it from within the instance of class Test that the message "equals" has been sent to.
It's less clear that "t.privateInt" should be visible, because t is a separate instance of class Test and we are not executing inside its equals method. However java allows this since both objects (t and this) are of the same class Test and can see each others private members.