Top "Static-initializer" questions

The static initializer is a static {} block of code inside java class, and run only one time before the constructor or main method is called.

What is the difference between a static and a non-static initialization code block

My question is about one particular usage of static keyword. It is possible to use static keyword to cover a …

java static static-initializer
Why doesn't Java allow to throw a checked exception from static initialization block?

Why doesn't Java allow to throw a checked exception from a static initialization block? What was the reason behind this …

java exception static-initializer
Use of Initializers vs Constructors in Java

So I've been brushing up on my Java skills as of late and have found a few bits of functionality …

java constructor initializer static-initializer initialization-block
In what order do static/instance initializer blocks in Java run?

Say a project contains several classes, each of which has a static initializer block. In what order do those blocks …

java static-initializer
Are Java static initializers thread safe?

I'm using a static code block to initialize some controllers in a registry I have. My question is therefore, can …

java multithreading static synchronization static-initializer
Java enum reverse look-up best practice

I saw it suggested on a blog that the following was a reasonable way to do a "reverse-lookup" using the …

java enums static-initializer
How to force a class to be initialised?

What is the best and cleanest way to do this? Specifically, I need some code in a static initializer block …

java coding-style static-initializer
How to check whether a class is initialized?

You'll probably ask, why would I want to do that - it's because I'm using a class (from an external …

java classloader static-initializer
.crt section? What does this warning mean?

I've got this warning recently (VC++ 2010) warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators I'm …

c++ visual-studio-2010 msvcrt critical-section static-initializer
get static initialization block to run in a java without loading the class

I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{ QuestionFactory.registerType("TrueFalse", "Question"); } public TrueFalseQuestion(){} } ... …

java static-members static-initializer