/ / -------------------------------------------------------------------------------------------- ----------------------------------------------------- ---------- Program start ------------------------------ // ---- -------------------------------------------------- --------------------- Public class test {public static void main (String [] args) {subclass sb = new subclass ();}}
Class Sssuper {INT I = -1; // for debug can delete static {system.out.println (1);} sssuper (int i) {system.out.println (i); this.i = i; // For debug can delete}}}
Class Subclass Extends Sssuper Implements Interface {Static {System.out.println (2);} Sssuper Su = New Sssuper (4);
Subclass () {super (3); //system.out.println (su1.i 1); // for debug can delete new sssuper (5);}}
Interface interface {static sssusuper su1 = new sssuper (0);
/ / -------------------------------------------------------------------------------------------- ----------------------------------------------------- ---------- The end of the program ------------------------------ // ---- -------------------------------------------------- ---------------------
Operation Conclusion: According to the test results, I know that the instance SU1 in Interface in Interface does not load when running, when //system.out.println (su1.i 1); // for debug can delete release SU1 began to load. This example can help us understand "Interface, inherit, and static block operation".