java中定义了一个有参数的构造函数,那么无形的构造函数有没了
classSuperClass{privateintn;SuperClass(intn){System.out.println("SuperClass("+n+")");...
class SuperClass {
private int n;
SuperClass(int n) {
System.out.println("SuperClass(" + n + ")");
this.n = n;
}
}
class SubClass extends SuperClass {
private int n;
SubClass(int n) {
System.out.println("SubClass(" + n + ")");
this.n = n;
}
SubClass() {
super(300);
System.out.println("SubClass()");
}
}
public class TestSuperSub {
public static void main(String arg[]) {
SubClass sc1 = new SubClass();
}
}
这个为什么会出错 展开
private int n;
SuperClass(int n) {
System.out.println("SuperClass(" + n + ")");
this.n = n;
}
}
class SubClass extends SuperClass {
private int n;
SubClass(int n) {
System.out.println("SubClass(" + n + ")");
this.n = n;
}
SubClass() {
super(300);
System.out.println("SubClass()");
}
}
public class TestSuperSub {
public static void main(String arg[]) {
SubClass sc1 = new SubClass();
}
}
这个为什么会出错 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询