If you simply have a K, that can apply to any type. You could add something like a List, which is a bad idea because Lists are mutable and you want immutable objectas as the “K” for a Map. But if you put a List in the Map, it doesn't implement Comparable, so that won't work. You want to assure the compiler that you will only put Comparable objects into the tree, so change its declaration toBy the way, a Comparable object may not implement Comparable to itself. So it might Comparable to its superclass, which you have to allow for. The usual declaration for Comparable is
Foo<T extends Comparable<? super T>> The second type parameter in a Map is usually V not T.
posted 5 months ago
Thank you for the reply and the welcoming!
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Create Edit Print & Convert PDF Using Free API with Java