0
  @Override
    public <E extends Enum<E>> E getValue(){
        return (E) super.getValue();
    }

Why is this overriding not working? The error that Idea is returning is that both methods have the same erasure but they are not overriding each other.

Edit:

Cannot Overload a Method Where the Formal Parameter Types of Each Overload Erase to the Same Raw Type

A class cannot have two overloaded methods that will have the same signature after type erasure.

public class Example {
    public void print(Set<String> strSet) { }
    public void print(Set<Integer> intSet) { }
}

The overloads would all share the same classfile representation and will generate a compile-time error.

Source: https://docs.oracle.com/javase/tutorial/java/generics/restrictions.html#cannotOverload

cgab
  • 45
  • 1
  • 1
  • 7

1 Answers1

1

The Parameter-Type is being erased at runtime. So the signature is identical.

Check one of the other solutions here for details.

Nikolas
  • 2,066
  • 1
  • 19
  • 20