Skip to content
Advertisement

Unable to override generic method in java

JavaScript

I am getting errors like

Main.java:12: error: TextMessage is not abstract and does not override abstract method setContent(T) in Message class TextMessage extends Message { ^ where T is a type-variable: T extends Object declared in method setContent(T) 1 error

Advertisement

Answer

Your method declaration:

JavaScript

hides the type parameter declared in class. That causes the error, most probably you don’t need that additional type parameter on the method.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement