A级
class A {
int a;
int c;
A (int a, int c) {
this.a = a;
this.c = c;
}
}
B类
class B extends A{
public static void main (String [] args) {
A obj = new A (5, 6);
}
}
当我编译代码时它告诉我这个错误
B.java:1: error: constructor A in class A cannot be applied to given types;
class B extends A{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
1 error
这个错误究竟是什么时候出现的?而在继承类的时候,构造函数必须是同类型的超类吗?