java - Will a class be loaded completely on static member dependency? -
this question has answer here:
- what “when class loaded” mean? 3 answers
public class extends b { public static final int const = 6; ... logic ... } public class c { private int addnumber(int x) { return x + a.const; } }
i wonder if junit test class c load field class a, depends on or if logic class extension (class b) loaded.
how jvm working in case ?
thanks !
on first reference class a, class loaded. given extends b, class b loaded well. static initializers , static fields in b executed/initialized in order specified in b, in a, , return code extracting const field.
wiki
Comments
Post a Comment