• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

When are Java static variables initialized?

If I have say:

Code:
    private static final ObjectA anObjectA = new ObjectA();

As soon as the program runs that gets initialized right? Even if the class/object aren't being used for some time?
 
IIRC, when the class is loaded (first time class definition referenced). I've been away from Java from some time, so YMMV.
 
Yes, when the class is loaded for the first time. It's one of the common ways of injecting bad code into a jar and getting it executed when the classes in the jar are loaded.
 
Back
Top