我的代码 -
public abstract class Level1Class
{
protected double num = 0.0D;
protected Level1Class(){}
protected Level1Class(double num){this.num = num;}
protected abstract methods A, B, C...etc //pseudocode !
}
public class Level2Class extends Level1Class
{
//NO CONSTRUCTORS HERE
//BUT, only implementation of methods A,B, C
}
public class Tester
{
Level2Class l2c = new Level2Class(10.0D); //This causes the compiler error !
}
有人可以告诉我为什么会出现此错误。我知道如果我在 Level2Class 中创建必要的构造函数,它就会成功。但是,我想知道原因。