So, I have this method:
protected void collectSelectedItems(ListSelectionModel lsm, Collection<? super MyItemClass> result) { for (int i : GUI.getSelectionIndices(lsm)) { result.add(getItemByDisplayIndex(i)); } }
I want to return the collection instead of the void method:
protected <T super MyItemClass> Collection<T> collectSelectedItems(ListSelectionModel lsm, Collection<T> result) { for (int i : GUI.getSelectionIndices(lsm)) { result.add(getItemByDisplayIndex(i)); } return result; }
with the intention of doing something like this (where MyItemClass extends MyItemBaseClass ):
List<MyItemBaseClass> list = collectSelectedItems(lsm, new ArrayList<MyItemBaseClass>());
but I get a syntax error on super :
Syntax error on super token, expected
What gives? Can i fix this?
java generics bounded-wildcard
Jason s
source share