>Can I initialise a static variable inside a non-static block,i.e {} without preceding static keyword?
Yes, you can. Because static members are accessible in non-static context too (reverse is NOT true). But it's not a good practice to do as
1.Intanse initializer will not be executed till you create an object. And so if somebody tries to access your static variable before any object of that class is created, unitialized value of the static variable will be used.
2.Instance initialializer will be executed whenever you create an object. It would be inefficient to assign the same value again and again to the same static variable!
3. It might create confusion later on.
-Paul.
------------------
SCJP2 Resources, Free Question A Day, Mock Exam Results and More!
www.jdiscuss.com Get Certified, Guaranteed!
www.enthuware.com/jqplus
Your guide to
SCJD exam!
www.enthuware.com/jdevplus