Why Map interface not extend Collection interface
Answer: Probably both could have been designed to re-use same common interface but some of the methods they implement are incompatible below are differences:
Collection | Map |
Collection interface represents group of objects known as its elements | Map interface is also an object which maps keys to values |
Collection interface has used to pass and work around collections of objects wherever maximum generality is desired | Where on Map interface each key could map to at least one value |
It has been designed to work on object | It has been designed to work on object with key value pair |
Methods they implements are incompatible. For example: Collection.remove(Object) – This removes object as an element. | Method implementation is incompatible. For example: Map.remove(Object) – This removes object by its key not by entry. |