public class Outer { private int outProp = 8; class Inner { private int inProp = 5; } public void accessInnerProp() { System.out.println(new Inner().inProp); } public static void main(String[] args) { Outer p = new Outer(); p.accessInnerProp(); } }
只是提示一下,外部类可以访问内部类的所有,只不过需要借助内部类对象