其他分享
首页 > 其他分享> > Some questions about Inner class and Outer class

Some questions about Inner class and Outer class

作者:互联网

class Outer {
    static int a=10;
    int b=20;
    int c=40;
    void fun(){
        Inner e=new Inner();
        e.g();
    }
     class Inner{
        int c=30;
        int b=50;
        Outer f=new Outer();
        static int d=50;
        public void g(){
            System.out.println(c);//30
            System.out.println(b);//50
            System.out.println(f.b);//20;
        }
    }
    void fum(){
        System.out.println(c);
    }
}
public class Main {
    public static void main(String[] args) {
        Outer a=new Outer();
        a.fun();

    }
}

  Question 1:Can an Outer class call an Inner class?

  Question 2:The order in which internal and external classes call member variables.

 

标签:about,Outer,int,System,Inner,class,out
来源: https://www.cnblogs.com/hzzzz/p/16196594.html