Basically, I want to have
public ImmutableList<? extends MyObject> getFilteredList(ImmutableList<? extends MyObject> initial) {
ArrayList<? extends MyObject> newList = new ArrayList<? extends MyObject>();
for (MyObject temp: initial) {
if (doesFulfillCriteria(temp)) newList.add(temp);
}
return newList
}
But the line
newList.add(temp);
gives me an error saying that newList expects <? extends MyObject>
, found MyObject instead.
Apparently I can't do something like
for (? extends MyObject temp: initial) {
either.
Please help?