public class Father {
public static String desc = "Father";
static {
System.out.println(desc);
}
Father(){
System.out.println("Father Constructor");
}
String str = fun();
public String fun(){
System.out.println("Father not static");
return "Father not static";
}
}
public class Child extends Father{
public static String desc = "Child";
static {
System.out.println(desc);
}
Child(){
System.out.println("Child Constructor");
}
String str = fun();
public String fun(){
System.out.println("Child not static");
return "Child not static";
}
public static void main(String[] args) {
Child c = new Child();
}
}
请问输出是什么,为什么,
我测试的输出:
Father
Child
Child not static
Father Constructor
Child not static
Child Constructor
关于Father static为什么不出来我不懂,求帮助