Ashik Uzzaman
Director of Engineering, Twin Health, Mountain View, CA, USA
Swati Kale
SCJP
SCWCD
Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</A>
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Originally posted by Jane Griscti:
Hi Kamil,
Initialization blocks are useful if you need an involved initialization statement for fields. For example, you may have a static field to hold the names of the months. You can declare a <code>static String[] months = new String[11];</code> and then place all the actual initialization code in a static initializer, just to make things a little neater.
Static initialization blocks are run only once, when the class is loaded. Instance initializer blocks are executed once for each new instance.
Hope that helps.
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
Don't get me started about those stupid light bulbs. |