P
pek
Here is a snippet:
class MyClass {
private int privateInt;
public void violateEncapsulation( MyClass e ) {
e.privateInt = 5;
}
}
Yes, this code works perfectly. The thing is, why? Somebody pointed me
to this: "The private modifier specifies that the member can only be
accessed in its own class." from http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
OK.. Now I kinda get it. But is there anybody out there that actually
used this type of code? Is it just Java or OO in general? Either case,
where does this help?
Thank you.
class MyClass {
private int privateInt;
public void violateEncapsulation( MyClass e ) {
e.privateInt = 5;
}
}
Yes, this code works perfectly. The thing is, why? Somebody pointed me
to this: "The private modifier specifies that the member can only be
accessed in its own class." from http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
OK.. Now I kinda get it. But is there anybody out there that actually
used this type of code? Is it just Java or OO in general? Either case,
where does this help?
Thank you.