java - Generic Comparable gets a compiler error -
this question has answer here:
- java generics - implements , extends 2 answers
i have code:
private class tree<t implements comparable<t>> { }
i expect put string objects tree, , string implements comparable, looked @ first glance.
but i'm getting error:
> expected private class tree<t implements comparable<?>> { ^
suggestions?
you need use
private class tree<t extends comparable<t>> { }
Comments
Post a Comment