Why can I access my private variables of the "other" object directly, in my equals(Object o) method

Viewed 6383

In Java in the equals(Object o) method I can access the private variables of the passed in object without going through its public getters.

public boolean equals(Object o){
    ...
    MyObject other = (MyObject)o;
    return getProp() == other.prop; 
}

How's that?

2 Answers
Related