This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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.