To be brief, I have:
public interface Dictionary<E extends Comparable<E>> extends Iterable<E> {
And
public class TreeDictionary implements Dictionary<TreeDictionary> {
When compiled, caused an error
TreeDictionary.java:4: type parameter TreeDictionary is not within its
bound public class TreeDictionary implements
Dictionary {
I guess the reason is probably because I’m not fully clear with the declaration of the Dictionary interface.
Would really appreciate if somebody could explain me this 🙂
That says that whichever type you want to use for
E, it must implement theComparableinterface.Given your
TreeDictionarydefinition:TreeDictionarydoes not implementComparable, and so cannot be substituted forEin the generic type ofDictionary.Try this instead:
TreeDictionaryshould now conform to the constraints ofE.