java 静态代码块,代码块,构造方法执行顺序

回顾一下java的执行顺序java

public class Demo {
    
    
    
    public Demo() {
        super();
        System.out.println("this is Demo");
    }ide

    static {
        System.out.println("this is static");
    }
    {
        System.out.println("this is {}");
    }
    
    
    
    public static void main(String[] args) {
        Demo demo=new Demo();
        //JobHandler jobHandler=new JobHandlerImpl();
        //jobHandler.excute();
        /*Handler handler=new Handler() {
            @Override
            public void handler1() {
                System.out.println("3123123123123123123");                
            }
        };
        handler.defaultMethod();
        Handler.staticMethod();*/
    }
}
this is static
this is {}
this is Demo
 this

相关文章
相关标签/搜索