Lets say I have function
void sell(Collection<? extends T> items) {
for (? e : items) {
stock.add(e);
}
}
as you can see i want to iterate through the items, but I cannot use the notation ? e, because it spits out the error “illegal start of expression”.
Each of the items in the collection is a
Tor a sub-class ofT, so you can useT. You don’t know the exact types of the items but that doesn’t matter; you do know their common base class.