Difference between the static initializer block and regular static initialization

后端 未结 8 2034
广开言路
广开言路 2021-01-05 12:12

As the title says, what exactly is the difference between

public static String myString = \"Hello World!\";

and

public stat         


        
8条回答
  •  没有蜡笔的小新
    2021-01-05 12:36

    Generally a static variable's value is shared between all instances (or the non-instance) of the Class it is defined in where a static block is a section of code that gets executed when Class is first loaded. Functionally There is no difference.

提交回复
热议问题