This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Private member accessible to other Objects..