So I was making a class the other day and used Eclipse's method to create the equals method when I realized that it generated the following working code:
class Test {
private int privateInt;
[...]
public boolean equals(Object obj) {
[...]
Test t = (Test) obj;
if ( t.privateInt == privateInt ) {
[...]
}
}
t.privateInt..???? It's suppose to be private! So I guess there is one more field visibility other than private, protected, package protected and public.
So what is happening here? How is this called? Where would somebody use this? Doesn't this break encapsulation? What if the class didn't have a mutator and I changed this? Does this happen to C++ as well? Is this an OO idiom? If not, then why did Java do it?
Generally, where can I find information about this?
Thank you.