• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Maop

 
sakthi moorthy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Map is not in a collection interface , But Set , List are in collection interface. My doubt is What are all the Collection interface Operations do the Map can not Perform When Compare With Set , List
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just take a look at the Collection and Map javadocs to find out for yourself?

As for the question of why Map is not a Collection, well, admittedly one can argue reasonably that a Map should indeed be considered some kind of Collection. But the designers of the Collections Framework ultimately decided that it's better to think of a Map not so much as a collection of objects, but rather as a relation between two collections. That's why the Map interface gives you accessors for the two underlying collections: keySet() and values(). You can then perform all your usual Collection operations on each of those two collections.

(However, Map also has an entrySet() method that muddles this view a little bit. You can read about that method in the javadoc, if you're not already familiar with it.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic