What is the Java static keyword? {}?

Possible duplicate:
Static block in Java

I came across the following use of static and did not understand what it was doing. I know to use, for example, static String hello = "World"; but I do not understand the following.

 static { loadFromProperties(new Properties()); } 
+4
source share
2 answers

He called a static initializer . This is a block of code that runs when the class initializes.

Related question (probably a duplicate actually):

+8
source

This is called static blocks. They are executed when the class is loaded / initialized, but before the instance is created. You can use to initialize static members / fields.

+3
source

All Articles