- class Outer//外部类。
- {
- private static int num = 4;
-
- static class Inner//内部类
- {
- void show()
- {
- System.out.println("Inner show run..."+num);
- }
-
- }
- }
-
- class InnerClassDemo
- {
- public static void main(String[] args)
- {
- Outer.Inner in = new Outer.Inner();
- in.show();
- }
复制代码
Inner是用static修饰的,但是show没用static修饰啊。。。可是为什么访问num时,要用static修饰num呢??? |