This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Why does HashSet implement Iterable?
HashSet is not ordered and a comparator object refers to the ordered collections - to iterate means to go through a collection / an array in ordered way. So what's up with HashSet?
HashMap is not directly iterable, but it does provide methods such as keySet() and entrySet() which return Set objects that are iterable. There's also values(), which returns a collection of the values in the map (which is also iterable).
The designers of interface java.util.Map could have chosen to make it extend Iterable<Map.Entry<K, V>>, so that you could directly iterate over the map's entries. But they didn't do that.