in the following snippet:
package test;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
public class WildcardsTest
Do it like this and it will work:
private final Iterator extends
Map.Entry>
> iterator;
You can still use the iterator like this:
public void foo(){
while(iterator.hasNext()){
Entry> entry = iterator.next();
Collection value = entry.getValue();
}
}
For reference, read the get and put principle (originally from Java Generics and Collections)