your question is not very clear to me. however, i am giving the following explanation,I guess it helps you.
static methods belong to the class and not any instance of the class, static code in a class is executed only once, when the class is initialized. and unless u create an instance, ie.. an object, u cannot use the non-static methods of the class. Anything in a class that is declared static is executed when the class is loaded.
I hope it helps..
Impossible is I M Possible
Joined: Sep 15, 2004
you might like to use the -verbose option . try to use it and go through the output that this option gives you..
The JVM loads a class either when the first instance of that class is created or the first time a static member of that class is referenced (even if an instance is never actually created).
So if there are no instances of that class, then calling one of its static methods will load the class.
When a class is loaded, the entire class file is loaded. At that time, static variables are initialized and static blocks of code are executed. Non-static members are initialized only if an instance is created -- but, again, the entire class loads at one time. [ September 18, 2004: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Loading is the first step in any execution. So when JVM loads the class it won't analyze to see what method is called and what isn't. It will load the entire class definition including static + member methods. Hope this answers your question.