java - How do I fix this bound mismatch error? -
by <item>
it's saying : -
bound mismatch: type item not valid substitute bounded parameter <t extends comparable<? super t>> of type expandablearraylist<t> expandablearraylist<item> items = new expandablearraylist<item> ();
these headers:
public interface listinterface <t extends comparable <? super t>> public class expandablearraylist<t extends comparable<?super t>> extends item { public class item implements comparable
i can't figure out need change exactly. every time change in 1 header other errors pop up. use compareto(object obj) type.
your item
class implementing raw form of comparable
interface. should have implement generic form, declaring type parameter on item
itself. then, expandablearraylist
can implement generic form of item
.
public class item<t extends comparable <? super t>> implements comparable<t>
and
public expandablearraylist<t extends comparable<?super t>> extends item<t>
this resolve compilation problems due headers.
but it's unclear why expandablearraylist
should subclass item
. should contain item
s; fails "is-a" test. expandablearraylist
shouldn't extend item
@ all.
Comments
Post a Comment