I've got a Collection with the element type of <K extends Comparable<K>>
because it's ordered.
I'm trying to use Joda LocalTime
with this collection - e.g. MyCollection<LocalTime>
. Unfortunately, apparently Joda is pre-generics; LocalTime
implements raw Comparable
.
I'm getting 开发者_如何学Cthe compiler error
Bound mismatch: The type LocalTime is not a valid substitute
for the bounded parameter <K extends Comparable<K>> of the type Interval<K>
I would expect this to work with just a warning, as it's quite possible to assign a raw type to a typed variable.
Why doesn't this work, and what can I do about it?
Here's a minimal code sample:
class Holder<K extends Comparable<K>> { }
class WTF extends Holder<LocalTime> { }
You could create a wrapper class around LocalTime
which implements Comparable<K>
and passes through all the method calls.
精彩评论