Skip to content
Advertisement

No suitable constructor found for java

I am getting the error message “no suitable constructor found” when the constructor I am trying to use only has one int parameter. When I try to create a new instance in another class with one int parameter, it is giving me that error. What am I doing incorrectly to cause this error?

JavaScript

the error is

JavaScript

Advertisement

Answer

Since MyPriorityQueue extends dHeap, and dHeap doesn’t have a no-arg constructor, you must call an appropriate constructor using super( ... args here ... ).

Since MyPriorityQueue is a dHeap, you’ll likely want to remove field queue, and replace queue = new dHeap<T>(queueSize); with super(queueSize).

You’ll also likely want to remove field size.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement