[Solved] error: method does not override or implement a method from a supertype

Compilation error:

error: method does not override or implement a method from a supertype

@Override

error: TestDocumentClipper is not abstract and does not override abstract method copyFromClipboard(DocumentInfo,DocumentStack,Callback,Injector) in DocumentClipper

The above is the compilation error caused by increasing or decreasing the parameters in the method when overriding the method of the parent class in a subclass, or when implementing the interface and overriding the method of the interface in a class
the above error messages are translated as:

1. Method does not override or implement the method in the supertype
2. Testdocumentclipper is not abstract and does not override the abstract method copyfromclipboard (documentinfo, documentstack, callback, injector) in documentclipper

Analysis:
when the documentclipper class implements the methods of the documentclipper interface, it adds (reduces) one more parameter, but there is no corresponding method in the interface to match, so it leads to compilation errors.

Solution:
Add (reduce) the same parameter to the corresponding method in the interface (parent class).

For example, you override the copyfromclipboard() method of the documentclipper interface in the documentclipper class. Because of necessity or carelessness, you add the parameter injector of type injector. The code is as follows:

@Override
public void copyFromClipboard(
        DocumentInfo destination,
        DocumentStack docStack,
        FileOperations.Callback callback,Injector injector){……

At this time, you need to find the copyfromclipboard() method in the documentclipper interface and add the same type of parameters

void copyFromClipboard(
            DocumentInfo destination,
            DocumentStack docStack,
            FileOperations.Callback callback,Injector injector);

Read More: