一道研究Java初始化顺序的程序题,有种你就来。

请大家仔细研究代码,直接写出控制台打印出来的顺序。

/**
 * Created with test
 * Description:
 * User: chenyuan
 * Date: 16/3/2
 * Time: 下午8:12
 */
public class Child extends Father {  
    static {
        System.out.println("child-->static");
    }

    private int n = 20;

    {
        System.out.println("Child Non-Static");
        n = 30;
    }

    public int x = 200;

    public Child() {
        this("The other constructor");
        System.out.println("child constructor body: " + n);
    }

    public Child(String s) {
        System.out.println(s);
    }

    public void age() {
        System.out.println("age=" + n);
    }

    public void printX() {
        System.out.println("x=" + x);
    }

    public static void main(String[] args) {
        new Child().printX();
    }
}

class Father {

    static {
        System.out.println("super-->static");
    }

    public static int n = 10;
    public int x = 100;

    public Father() {
        System.out.println("super's x=" + x);
        age();
    }

    {
        System.out.println("Father Non-Static");
    }

    public void age() {
        System.out.println("nothing");
    }
}

明天公布答案。^_^