I came across this Java code:
static {
String aux = \"value\";
try {
// some code here
} catch (Exception e) { }
String UUID_prefix =
This is a static initialization block. Think of it like a static version of the constructor. Constructors are run when the class is instantiated; static initialization blocks get run when the class gets loaded.
You can use them for something like this (obviously fabricated code):
private static int myInt;
static {
MyResource myResource = new MyResource();
myInt = myResource.getIntegerValue();
myResource.close();
}
See the "Static Initialization Blocks" section of Oracle's tutorial on initializing fields.