All the code blocks that do not have a function name and are declared as static are executed before the constructor is called. They are usually used to initialize static fields as shown in below code. Java Code: This is an example of static initialize public class StaticInitilaizer { public static final int A = 5; public static final int B; //Static initializer block, which is executed only once when the class is loaded. static { if(A == 5) B = 10; else B = 5; ...
public class StaticInitilaizer { public static final int A = 5; public static final int B; //Static initializer block, which is executed only once when the class is loaded. static { if(A == 5) B = 10; else B = 5;
Updated 01-14-2012 at 06:37 PM by Java Basic
Size Reduced for Images in PDF &...
05-15-2013, 05:53 PM in Java Software