A test interface is loaded, and the class is loaded well.

xiaoxiao2021-03-13  195

/ / -------------------------------------------------------------------------------------------- ----------------------------------------------------- ---------- 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".

转载请注明原文地址:https://www.9cbs.com/read-129096.html

New Post(0)