1.4 如何在main()方法之前执行输出“hello world”

public class Test{
    static{
        System.out.println("hello world");
    }
    public static void main(String[]args){
    }
}

  不管static的位置在哪,静态块的执行都是在main()方法之前。

posted @ 2018-02-08 13:43  leerle  阅读(251)  评论(0编辑  收藏  举报