The Java Language Specification says this about enum
constants
In addition to the members that an enum type E inherits from Enum, for each declared enum constant with the name n, the enum type has an implicitly declared public static final field named n of type E. These fields are considered to be declared in the same order as the corresponding enum constants, before any static fields explicitly declared in the enum type. Each such field is initialized to the enum constant that corresponds to it.
So
enum Color {
RED, BLUE, GREEN;
...
}
is actually
public static final Color RED = new Color();
public static final Color BLUE = new Color();
public static final Color GREEN = new Color();
which will get evaluated before the static
blocks you have.
Why do the init blocks marked static run last in an enum?
See above.
Can an enum have instance init blocks?
Yes, compile your code and you will see.
Why do the blocks I thought were instance init blocks run only once when the enum is loaded and not each time a new enum value is referenced?
Enum constants are created (instantiated) once the enum type is initialized. You don't create a new enum
any time you do
Color color = Color.RED;
You are just referencing an already created, existing object.
Class static init blocks run when a class is "loaded". What does loaded mean? Does it occur just once when an object is instantiated in the class?
When a class is referenced in the JVM for the first time, it is loaded by the ClassLoader
and initialized. Read more about it here.