This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I keep running into confusion while trying to make since of all the different collection classes/interfaces.
First off, why doesn't the Map interface extend the Collection interface? Is it solely because a Map takes a key/value pair?
Also, What are the properties of a Collection (capital C - interface)? What I mean is a List (which extends Collection) is unique because it defines the methods that relate to an index like get(int). So what defines something that IS-A Collection that makes it unique from something that IS-A Map?
why doesn't the Map interface extend the Collection interface? Is it solely because a Map takes a key/value pair?
Yes. Collection represent a collection of objects while a Map represents a key/value pair.
what defines something that IS-A Collection that makes it unique from something that IS-A Map?
Again I think the answer is the same. Collection interface provides methods such as add which lets you add an element to the collection. Map provides methods such as put which takes two arguments i.e. a Key and Value...
Thanks for the reply Ankit! I do understand that... I guess my question was more focused on the reason behind why they did it that way? For instance why didn't they just have the Map interface extend the Collection interface and then overload the add method to accept 2 objects instead of 1? I know they had a good reason, and I'm sure it's a simple one... I just keep thinking that if I can understand why it is set up the way it is then I'll also understand much better how it works (and why).