I am implementing a class to store objects that can be assigned a double value. For this reason, I have created a HasDoubleValue interface, that contains a single method:
public interface HasDoubleValue{
public double doubleValue();
}
My main class is defined as such:
Data <O extends HasDoubleValue> {...}
Now, when I try to initialize this class to store Integers, I get a "type argument Integer is not within bounds of type-variable O" error, although Integer implements the doubleValue() method by default.
I suppose that this happens because Integer does not explicitly implement my HasDoubleValue interface, although it has the method I am looking for. Is this right? What would a natural workaround be?