I can't grasp why my interface parametrization doesn't work. Let's look at code below:
public interface IType {
public List<String> getAllItems();
}
......
public void function(IType item) {
for (String str : item.getAllItems()) { //DOESN'T WORK! Incompoatible types. Required String, Found: Object
}
}
Why does it return List<Object>
instead of List<String>
?