class Test{
static{
System.out.println("this is static block");
}
Test(){
System.out.println("this is Constructor");
}
public static void main(String[] args){
Test t=new Test();
}
}
先执行类的静态代码块
static{
}
再执行构造方法
Test(){
}
class Test{
static{
System.out.println("this is static block");
}
Test(){
System.out.println("this is Constructor");
}
public static void main(String[] args){
Test t=new Test();
}
}
static{
}
Test(){
}