I want to have a generic class that implements Iterable (let's call it ImplIterable) of type T that implements an Iterable interface over some class (that isn't of the generic class type); for example:

I don't understand why the latter doesn't compile and why can't I iterate over ImplIterable if it properly implements iterable. Am I doing something wrong/is there some workaround for this type of problems?

Thanks! I didn't know generics worked this way. ImplIterable<Void> works, as does any type. So the former case works because the generic type in Iterable<A> isn't erased - which makes sense in a way.
–
BartekMar 18 '11 at 20:20

You're welcome. This happens for compatibility reasons. You should accept this answer by clicking the hollow check.
–
SLaksMar 18 '11 at 20:29