Java: When is a static initialization block useful?

前端 未结 13 1669
时光说笑
时光说笑 2020-11-30 16:49

What\'s the difference between initialization within a static block:

public class staticTest {

    sta         


        
13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 17:06

    static block can be used to initialize singleton instance, to prevent using synchronized getInstance() method.

提交回复
热议问题