Java: When is a static initialization block useful?

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

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

public class staticTest {

    sta         


        
13条回答
  •  日久生厌
    2020-11-30 17:18

    A static initialization block is useful if one, you wish to intialize specified class static types, prior to the class first use. Subsequent use will not invoke any static initialization blocks. It's the direct opposite of instance initializers, which initialize instance members.

提交回复
热议问题