We know Map is an Interface which is being implemented by classes HashMap, TreeMap...
Since all these implementing classes have same entry pattern (i.e. key-value pair), why should not we have this Entry pattern within Map Interface itself?
What is the purpose to have this Entry pattern separately as Interface that is nested inside Map Interface?
Thanks in advance.
Mapis in a sense a collection ofEntryobjects. How would you expect it to be an entry? Can you give an example of howMapwould be defined as an interface/contract to implementEntry? - ernest_kEntrybelongs toMap, i believe they wanted to put it inside theMapinterface. - GlainsEntryare related to that single entry. The methods of aMapare related to all the entries.Entryhas a methodgetKey(), if it was inMap, which key would it return? - jbx