0

Intuitive, I would say a Map/Dictionary, ect. is a Collection. Why is a Map (Interface) in Java not an extension (extends) of the Collection (Interface).

lazyboy
  • 301
  • 3
  • 12
  • Map and dictionary are collections (small c), as they are part of the collections framework; they just don't implement `Collection` because they require different methods to things like `List`. Perhaps that is a failing in the choice of "Collection" as the interface name. – Andy Turner Jan 19 '16 at 10:28
  • Collection has been given a specific meaning of a collection of elements, it doesn't apply to any collection as we might describe it in English. A Map is a collection of values associated with a key. – Peter Lawrey Jan 19 '16 at 10:46

1 Answers1

0

A Map doesn't have some of the methods of the Collection interface (such as add, contains, etc...), so it can't extend that interface.

A Collection represents a group of elements of a single common type. A Map does not - it represents a mapping of elements of one type (called keys) to elements of another type (called values).

Eran
  • 387,369
  • 54
  • 702
  • 768