You try to do something for each Iterable
inside the iterable
. This would only make sense if iterable
was an Iterable<? extends Iterable>
(i.e. it would iterate over yet other Iterable
objects).
But since you didn't specify a type argument for the argument, you only know that it will iterate over some kind of object (i.e. the base type Object
is applicable).
You should try this:
for (Object o : iterable) {
System.out.println(o);
}
When read out loud it read as "For each Object
o
in iterable
, print o
". Replacing Object
in that sentence with Iterable
should illustrate what the problem was.