I would rather expect that private member is private to all Objects... If I would make class Person and private member named bankAccountNumber... Why other Objects of class Person should be able to read something that is private to them??
Why Java creators have decided to do something like that?
A private class member or constructor is accessible only within the body of the top level class (�7.6) that encloses the declaration of the member or constructor.
In your example, a1 is defined in the body of the top level class, so it's accessible in class A's method modifyOther.
This is why we can write equals() classes that include statements like
Writing proper clone methods could be very painful and overly verbose if you couldn't access private member variables.
Think of it this way - Object A knows all about how it's implemented. Why pretend that it doesn't? It's up to you as the programmer to decide that if A instance a1 and A instance a2 can muck with each other directly through proper encapsulation.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James