Skip to content
Advertisement

How to resolve `Raw use of parameterized class ‘Comparable’` warning?

Got to implement the method below for an assignment which it’s subject is “WildCards”, but don’t know where to use wildcards in order to resolve the warning.

JavaScript

Any ideas ?

Advertisement

Answer

Comparable is a generic interface, so to use it safely you must always specify the generic type to use. In your case, something like:

JavaScript

is likely what you’re looking for. Otherwise, the compiler is unable to help you verify that the types are actually compatible in all scenarii.

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