静态代码块

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

 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();//语句(*) 
} 
}