Static code block
•
Java
Here is the programming house jb51 CC collects and arranges code fragments through the network.
Programming house Xiaobian now shares it with you and gives you a reference.
class Parent{ static String name = "hello"; { System.out.println("parent block"); } static { System.out.println("parent static block"); } public Parent(){ System.out.println("parent constructor"); } } class Child extends Parent{ static String childName = "hello"; { System.out.println("child block"); } static { System.out.println("child static block"); } public Child(){ System.out.println("child constructor"); } } public class StaticIniBlockOrderTest { public static void main(String[] args) { new Child();//语句(*) } }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码