Oxfam America banner

Friday, August 1, 2008

Iterators are of course not Iterable!

This amuses me to no end:



Iterator iter = properties.getKeys();
for (String key : iter) {
// do something with the key
}

The above java will not compile, and the error is "Can only iterate over an array or an instance of java.lang.Iterable." Apparently an Iterator isn't iterable! Wow! Isn't that so convenient?

0 comments:

Post a Comment