• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Set and Map

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats is the difference between above two?
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rajesh
A Set can not have duplicate values. While a map's Value can be duplicate but it's key can not be.
Let's take an example.
Consider the roll No. used in schools/colleges etc.
Here the roll no. is unique but the name may or may not be unique. So this is an example of a map where the name is the value(may be repeated) and roll no. is the key(unique).
You can consider a set as one, only containing values and that too unique.
Consider the set of all the english alphabets(A-Z). In this set we have only unique elements that is no alphabet can be repeated.
Hope that helps. Repost if it doesn't.
[ June 29, 2003: Message edited by: Anupam Sinha ]
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map: Key/value pair. One implementation of Map interface allow null key/values (hashmap) and others don't (hashtable). duplicate keys are not allowed.
Set: when you see a Set, think of no duplicates.
HTH
[ June 29, 2003: Message edited by: Andres Gonzalez ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic