C/C++教程

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.

 

这篇关于Some questions about Inner class and Outer class的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!