first post here...
Here is a generic class I have defined:
public class TimeSeries<T extends Number> extends TreeMap<Integer, T>{
...
public Collection<Number> data() {
return this.values();
}
}
A bit of context. TimeSeries is basically a specific kind of TreeMap, where the keys are Integers and the values are Numbers.
My issue is that the data method breaks with the following error:
error: incompatible types: Collection<T> cannot be converted to Collection<Number>
return this.values();
^
where T is a type-variable: T extends Number declared in class TimeSeries
values method just returns a Collection of T. Why exactly can't I return this out of the method if I have specifically stated that T extends Number?
Thanks in advance.