No, it loads classes whenever they are first referenced, either through Class.forName()
or through direct use in your code.
Example:
public class First {
static {
System.out.println("first");
}
public static void main(final String[] args) {
System.out.println("second");
Second.third();
}
}
public class Second {
static {
System.out.println("third");
}
public static void third() {
System.out.println("fourth");
}
}
If you run First
as a main class, the output is:
first <-- First is loaded
second <-- method in First is executed
third <-- Second is loaded
fourth <-- Method in Second is executed