Whethere the sequence i hav written is correct or not.. 1) First static variables 2) Static block 3) Main method 4) Non Static variables..
If anybody has any good link kindly share it...
Praveen Babu
Ranch Hand
Joined: Jul 30, 2006
Posts: 138
posted
0
Hi,
The Sequence is right but there is one more thing you might want to know that is , after main method the non-static blocks(eg., blocks like {System.out.println();} ) are executed.Also, first the static variables are initialized with their default values(say 0 for int) then static blocks are executed in order of apperance and then the static variables are executed in order of their appearance
See the code below which shows the same.
and the o/p is:
---------- o/p ---------- static one static two 5 one three two hmm...
Bye & Regards, Praveen
[ August 10, 2006: Message edited by: praveen babu ]
[ August 10, 2006: Message edited by: praveen babu ] [ August 10, 2006: Message edited by: praveen babu ]