package day18;
class Z {
public Z() {
System.out.println("z");
}
}
class F {
public F() {
System.out.println("f");
}
}
class Fu {
static {
System.out.println("Fu静态");
}
F f = new F();
public Fu() {
System.out.println("fu");
}
}
class Zi extends Fu{
static {
System.out.println("静态");
}
Z z = new Z();
public Zi() {
System.out.println("zi");
}
}
public class Demo_Extends {
public static void main(String[] args) {
Zi z = new Zi();
}
}
这个代码我试过了
答案是
Fu静态
静态
f
fu
z
zi
我拿断电调试了一下,发现走构造方式时候回跳到该类的成员变量处,不太懂,求解 |
|