关于Java中的内部类的问题
public class Program1 {public static void main (String[] arks) {
A a = new A ();
B b = a.new B (); // 没有语法错误呀,这个内部类也是public的,莫名其妙!
Program1 p = new Program1 ();
C c = p.new C ();
c.test ();
}
class C {
public void test () {System.out.println ("good");}
}
}
class A {
public class B {
public void method () {System.out.println ("Hello Inner Class ?");}
}
}
为什么是错的?