Skip to content Skip to sidebar Skip to footer

Java/android Studio - Covariant Return Type - Method In "subclass" Clashes With Method In "baseclass": Attempting To Use Incompatible Return Type

I am currently trying to apply a covariant return type in the following situation (code is truncated heavily for relevance): Attribute class: public abstract class Attribute

Solution 1:

You do not return a Doubleclass. You return a primitive double. A primitive type can not be a subclass of an object.

publicdoublegetValue() //The error shows on 'double'
{
    returnthis.value.doubleValue();
}

change to (Uppercase D)

publicDouble getValue() //The error shows on 'double'
{
     returnthis.value;
}

Post a Comment for "Java/android Studio - Covariant Return Type - Method In "subclass" Clashes With Method In "baseclass": Attempting To Use Incompatible Return Type"