public class test {static int num; static int numobj; // records how many objects are generated! Static {// static code block, used to initialize the class! // Num = 10; ++ num; num * = 12; // before entering the static code block, the num initialization value is 0 system. out. println (Num); // main (null); // you can call main in a static code block. If you think about it, it is static!} // Execute the constructor code segment first, and then the row constructor {// This is called the constructor code segment. You can initialize all objects! Every object is executed when it is generated! ++ Numobj; system. Out. println ("construct a code segment! ");} Public test () {// count the object instance in the constructor // + numobj; system. Out. println (" constructor! ");} Public void finalize () {// call system. Out. println (" Object release! "); -- Numobj;} public static void show () {system. out. println ("number of instances created:" + numobj);} public static void main (string [] ARGs) {system. out. println ("the static code segment is used to initialize the class! "); Test T1 = new test (); t1.show (); {// partial code segment new test ();} system. GC (); // start the Garbage Collector! New Test (); new test (); system. Out. println (test. numobj) ;}