Thursday, 29 August 2013

Inner class method and private fields

Inner class method and private fields

Why inner class have access to private field of input object param of such
class?
private class Inner {
private int privatefield = 0;
public void method( Inner inner ) {
privatefield = 1; //ok
inner.privatefield = 1; //this line confusing me (broken
incapsulation)
}
}

No comments:

Post a Comment