package com.company.java.oop.cls; class ClassF { // static ClassF instance =new ClassF(); static { System.out.println("static{}.b =" +ClassF.b ); } S Tatic final int B = 10 ; // optimizing compiler belonging to add the final keyword, initialization is complete, all of the printing in the static block is 10, and 0 if not static . } public class TestClassObject09 { public static void main(String[] args) throws ClassNotFoundException { Class.forName("com.company.java.oop.cls.ClassF"); } }
package com.company.java.oop.cls; class ClassF { static ClassF instance = new new ClassF (); // instantiate public ClassF() { The System. OUT .println (B); B is 10, if a final int b is not the case then modified 0. } static { System.out.println("static{}.b =" + ClassF.b); } static final int B = 10 ; // optimizing compiler belonging to add the final keyword, initialization is complete, all of the printing in the static block is 10, and 0 if not static. } public class TestClassObject09 { public static void main(String[] args) throws ClassNotFoundException { Class.forName("com.company.java.oop.cls.ClassF"); } }