I have following code setup. But this is not allowed as wildcard is not allowed for Iterable.
public interface CustomInterface extends Iterable<? extends MyBaseType>{....}
CustomTypeA extends MyBaseType{....}
class CustomImpl implements CustomInterface {
List<CustomTypeA> listA = new ArrayList();
@Override
public Iterator<CustomTypeA> iterator() {
return listA.iterator();
}
}
What actually Java tries to a achieve here by not allowing this? What modifications would get this working?