public class HelloJava{
public int a;
public static void main(String[] args) {
System.out.println(B.f); //输出3
}
}
class A{
static int f;
static {
f = 3;
}
}
class B extends A{
static {
f = 2;
}
}
public class HelloJava{
public int a;
public static void main(String[] args) {
System.out.println(B.f); //输出3
}
}
class A{
static int f;
static {
f = 3;
}
}
class B extends A{
static {
f = 2;
}
}
本文标题:java继承中的静态块
本文链接:https://www.haomeiwen.com/subject/lmfpxhtx.html
网友评论