Pages

Thursday, April 12, 2018

There is no default constructor available in Foo

There is no default constructor available in Foo

I tried to inherit an existing Java Class. When I tried, I got an compiler error stating,

There is no default constructor available in Foo

There are two ways to solve this issue.
1. Add a default Constructor (with no arguments) to the Parent

This post is about the second way. No need to adding default constructor in the parent.
In the derived class, just add this line in the parameterized constructor.

super(a, b, ...);


Reference:
https://stackoverflow.com/questions/17068389/default-constructors-in-java

No comments:

Post a Comment