is Calling a static Java method ( a factory class method ) creates an object of that Class ?
I mean a static method returns a value let’s say an Array’s size ( array is variable of class )
I’ve checked the code but couldn’t see that the Object of that class never instantiated before calling the static method. ?
public static boolean isFiveInstance() {
return _instances.size() == 5;
}
and _instances is class variable
private static ArrayList<LocalMediaPlayer> _instances;
and is being created and filled in the constructer.
No,
staticinvocations do not instantiated objects (because they do not require one).The first time you refer to a class, including static method invocation, the class is loaded. by the classloader.
That’s where the static initializer comes into play:
this block is called whenever the class is initialized (once per classloader)