- class Outer
- {
- private int num=20;
- public void show()
- {
- final int num=30;
- class Inner
- {
- private int num=40;
- public void show2()
- {
- int num=50;
- System.out.println(num);//为什么不能访问30的num的数?
- }
- }
- Inner i=new Inner();
- i.show2();
- }
- }
- class InnerDemo1
- {
- public static void main(String[] args)
- {
- Outer o=new Outer();
- o.show();
- }
- }
复制代码 |