I am sure that many of us feel very warm and safe in knowing fundamental facts about Java. For example, a class variable like
private int h;
cannot be modified by any object other than the class it exists in, right?
Wrong – otherwise why would I waste my time here? The issue popped up when I was writing my solution to a class assignment and I noticed that instances of the same class can access each other’s private member variables.
Further investigation on the Java Tutorial reminded me of the very fundamental fact that the private
access modifier specifies class visiblity, NOT instance visiblity. Definitely not something anyone would recommend using, just something you should keep in mind. Always.