class A {
static {
System.out.print("1");
} public A() {
System.out.print("2");
}
}class B extends A{
static {
System.out.print("a");
} public B() {
System.out.print("b");
}
}public class Hello {
public static void main(String[] args) {
A ab = new B();
ab = new B();
}
}为什么是1a2b2b,能说一说原理吗?
添加回答
举报
0/150
提交
取消