Java: When is a static initialization block useful?

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

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

public class staticTest {

    sta         


        
13条回答
  •  情书的邮戳
    2020-11-30 17:11

    Sometimes you want to do more than just assign values to static variables. Since you cannot put arbitrary statements in the class body, you could use a static initializer block.

提交回复
热议问题