Compiler Error J0061

The members 'identifier' and 'identifier' differ in return type only

The compiler detected a subclass method attempting to overload a base class method, but the methods differed only in return type. In Java, overloaded methods must be distinguished by unique signatures. A unique signature consists of the method name, the number, type and positions of its parameters, and the return type.

The following example illustrates this error:

public class Simple extends Simple2 {
   
   public void method1() {
      // error: only return type differs
   }
}

class Simple2 {
   
   public int method1() {
   
      return 1;
   }
}