class StaticSuper{
static{
System.out.println("super static block")
}
StaticSuper{
System.out.println("super constructor");
}
}
public class StaticTests extends StaticSuper{
static int rand;
static{
rand=(int)(Math.random()*6);
}
StaticTests(){
System.out.println("constructor");
}
publci static void main(String[] args){
System.out.pringln("in main");
StacticTest st =new StacticTests();
}
}
上面这段的输出顺讯是这样的
super static block
static block 3
in main super constructor
constructor
在下小白。。谁能帮忙解释一下为什么是这个输出顺序
另外
像这种,是什么意思?是方法?构造函数?还是啥意思,为啥没有()符号
StaticSuper{
System.out.println("super constructor");
}