Do you need to use Iterable<? extends MyInterface> Iterable<? extends MyInterface> instead of Iterable<MyInterface> , because although Constants is a subtype of MyInterface , Iterable<Constants> not a subtype of Iterable<MyInterface> - and I will show you why:
If this were the case (it is acceptable to use List instead of Iterable for the following example), I could do this:
List<Constant> constantsList = new ArrayList<Constants>(); // list of constants List<MyInterface> ifaceList = constantsList; // you said this would be OK ... // assume MyOtherImplementation is another implmentation of MyInterface ifaceList.add(new MyOtherImplementation()); // OK, MyOtherImplementation implements MyInterface Constant myConst = constantsList.get(0); // Oops! I just got an instance of MyOtherImplementation from List<Constant> - not cool.
source share