- package sort;
- class Outer {
- private int x =3;
- class Inner
- {
- void function(){
- System.out.println("inner"+x);
- }
- }
- void method(){
- Inner in = new Inner();
- in.function();
- }
- }
- class Classmain
- {
- public static void main(String[] args) {
- Outer.Inner in = new Outer().new Inner();//直接访问内部类的成员
- in.function();
-
- }
- }
复制代码 |
|