Constructor cannot be applied to given types?

A subclass does not have to have any constructor with “the same number of parameters in the constructor as the superclass”, but it does have to call some of its superclass’ constructors from its own constructor.

If the superclass has a no-arg constructor, it is called by default if an explicit call to a superclass constructor is omitted or if the subclass has no explicit constructor at all (as is your case), but since your superclass does not have a no-arg constructor, compilation fails.

You could add something like this to your EmptyList:

private EmptyList() {
    super(0, null);

It may also be a better idea to have an abstract superclass that both of your classes inherit from, instead, but that’s a choice.

Leave a Comment