Java no name static method

后端 未结 2 1027
滥情空心
滥情空心 2021-02-01 17:41

What is this?

public class ABC {
   public ABC() {
         System.out.println(\"world\");
   }
   static {
         System.out.println(\"hello\");
   }
}
         


        
2条回答
  •  死守一世寂寞
    2021-02-01 17:59

    I think it's worth noting the static block will be run exactly once each time a classloader loads a class. This means if you have more than one classloader, the block can execute more than once.

提交回复
热议问题