Why can't we use Iterator on a Map(Java)?
<p>I understand that to iterate through a <code>Map</code>, I need to use the <code>entrySet()</code> method and then use the <code>Iterator</code> on the resultant <code>Set</code>. I feel the question might be silly, but, how is the <code>Map</code> exactly implemented so that using an <code>Iterator</code> on it directly isn't possible? As far as I understand, <code>Map</code> isn't a collection, and <code>Iterator</code> is meant to be used over a collection. But logically, isn't <code>Map</code> also a collection of key-value pair(though it doesn't implement the <code>Collection</code> interface)?</p>
