What does Static {} mean in the Java Syntax?

后端 未结 7 1261
野趣味
野趣味 2020-12-13 13:49

I came across this Java code:

static {
    String aux = \"value\";
    try {
        // some code here
    } catch (Exception e) { }
    String UUID_prefix =         


        
7条回答
  •  星月不相逢
    2020-12-13 13:59

    This is a static initializer block. You must have found it in a class's body outside of any method. The static init block runs only once for each class, at classload time.

提交回复
热议问题