What is the difference between Map and collection in java?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is the difference between Map and collection in java??

28th Aug 2018, 12:35 PM
Keerttik Titan
Keerttik Titan - avatar
4 Answers
+ 7
okay i figured it out.. Collection----- if we wish to represent group of individual object as a single entity. ex:- Arraylist, linked list, vector, stack, queue etc. Maps---- if we want to store both value and the key (key, value pair) then we use mapping concept. ex:-hashmap,treemap etc
28th Aug 2018, 1:24 PM
Keerttik Titan
Keerttik Titan - avatar
+ 3
Keerttik Titan list interface and classes which implements it comes under collection interface
28th Aug 2018, 1:19 PM
Nao
Nao - avatar
+ 3
yes 👍
28th Aug 2018, 1:27 PM
Nao
Nao - avatar
+ 2
map works on key whereas collection works on index basically map is used when we dont want duplicate objects (as keys are unique)
28th Aug 2018, 12:39 PM
Nao
Nao - avatar