Java中的初始化顺序

public class Test
{

    {
        System.out.println("In non-static initialization block!");
    }

    static
    {
        System.out.println("In static initialization block!");
    }


    public Test()
    {
        System.out.println("In Constructor1!");
    }


    public void show()
    {
        System.out.println("In show()!");
    }


    public static void main(String[] args)
    {
        Test ti = new Test();
        ti.show();
    }

}

 

搞不明白,既然已经有了构造函数,为什么还要非静态初始化块呢.....

你可能感兴趣的:(java)