, : , . T ? , . , , , : T Comparable <T> , , , , , :
Foo Comparable < >
So the actual implementation should be T extends Comparable <? super T>. Nice and not so difficult. But then we get things like Enum <E extends Enum <E โ and really, explain it to someone without confusing it - good luck with that.
So, Generics are useful and easy to use, but extremely difficult for WRITE to do correctly (and don't make me start writing the right binary backward compatible versions of the existing library - see the lib compilation in the JDK). Fortunately, only a small portion of library writers need this right for everyone else to benefit from it.
source
share