How to solve There is no such method error

I am working on a swing application in netbeans. I created one parent class and a child class. Whenever I call any attribute of the parent class through the child class, I get an error. How to solve it:

this is the parent class:

public abstract class WorkRequest {

private String name;
public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}}

this is a child class:

public class DoctorTestWorkRequest extends WorkRequest {

private String message;

public String getMessage() {
    return message;
}

public void setMessage(String message) {
    this.message = message;
}

I call the child class in the panel:

DoctorTestWorkRequest request = new DoctorTestWorkRequest();
    request.setName(name);
    request.setMessage(message);

I get an exception:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: Business.WorkQueue.DoctorTestWorkRequest.setName(Ljava/lang/String;)V
at UserInterface.ReceptionistRole.DoctorTestWorkRequestJPanel.requestTestJButtonActionPerformed(DoctorTestWorkRequestJPanel.java:147)

How to solve it. thank you in advance

+4
source share
2 answers

The problem may be in the IDE cache, so to solve this problem, rename the WorkRequest class to WorkRequestNew and use the new name in

public class DoctorTestWorkRequest extends WorkRequestNew

hope this helps.

+1
source

WorkRequest DoctorTestWorkRequest

WorkRequest request = new DoctorTestWorkRequest;

-3

Source: https://habr.com/ru/post/1616694/


All Articles