Ques: Can one object can access a private variable of another object of the same class? Ans: YES. Private means "private to the class", NOT "private to the object". So two objects of the same class could access each other's private data.
I want to understand (with an example probably) how. Please can someone help.
Take a quick look at the Comparable interface and the compareTo method. This asks an object to compare itself to another object, usually another instance of the same class. It often winds up like this:
If "field1" is private, we need to access the private field of the "other" instance. And Java lets us.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi