class Demo1_InnerClass { public static void main(String[] args) { //Inner i = new Inner(); //i.method(); //外部类名.内部类名 = 外部类对象.内部类对象 Outer.Inner oi = new Outer().new Inner(); //创建内部类对象 oi.method(); }}class Outer { private int num = 10; class Inner { public void method() { System.out.println(num); } }} |
|