I have a Class(call it main class) and the method in main class calls methods of other classes.I have extended this main class in all other classes like this
public class Evaluate extends Main
in my main class i am using swingworker ,so i have written the code like this
class Main extends SwingWorker<Void, Void>{
public Main(GUI frame) {
p = frame;
}
//some more code
Now when i build this program, it gives me the following error
error: constructor Main in class Main cannot be applied to given types;
public class Evaluate extends Main {
required: GUI
found: no arguments
reason: actual and formal argument lists differ in length
Here GUI contains the main method from where my application starts.Kindly help me why this error is occurring.
When you extend a class, you should call a constructor of the main class in your own constructor (by using
super). So in this case, yourEvaluateclass should look likeCheck out the excellent Java tutorial for more information, and certainly the section about Subclass constructors