Why can nested child classes access private members of their parent class, but grandchildren cannot?
<p>Probably similar to the question, <a href="https://stackoverflow.com/questions/1801718/why-can-outer-java-classes-access-inner-class-private-members">Why can outer Java classes access inner class private members?</a> or <a href="https://stackoverflow.com/questions/31478718/access-to-superclass-private-fields-using-the-super-keyword-in-a-subclass">Access to superclass private fields using the super keyword in a subclass</a> .</p>

<p>But there are some differences: the children class can access the private members of their parent (and <strong>only the nearest parent</strong>) class.</p>

<p>Given the sample code below:</p>

<pre><code>public class T {

    private int t;

    class T1 {
        private int t1;

        public void test() {
            System.out.println(t);
        }
    }

    class T2 extends T1 {

        private int t2;

        public void test() {
            System.out.println(t);
            System.out.println(super.t1);
            System.out.println(this.t2);
        }
    }

    class T3 extends T2 {

        public void test() {
            System.out.println(t);
            System.out.println(super.t1); // NG: t1 Compile error! Why?
            System.out.println(super.t2); // OK: t2 OK
        }
    }
}
</code></pre>