• 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

Map vs. Set

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between a Map and a Set?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a question you can answer for yourself by looking at the Java SE Javadoc API. Both Map and Set are in the java.util package. If you have questions about what you read, let us know and we'll try and clarify.
[ March 12, 2007: Message edited by: Merrill Higginson ]
 
Ra Carter
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well... thanks for nothing since i already knew where the documentation was... but actually i was confused by HashSet vs. HashMap. I see now that sets are not key-value pairs but rather just a list of values that can not be duplicated.

did i state that correctly?
[ March 12, 2007: Message edited by: Ra Carter ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"I see now that sets are not key-value pairs but rather just a list of values that can not be duplicated. did i state that correctly?"

Yes, that's right.

"well... thanks for nothing ..."

Looking at the documentation did help you find the anwer, didn't it?
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following code example will make the distinction clear.
A HashMap is a combination of <key,values> where the hashcode of the key determines the efficiency.

A HashSet is a set of values which hashcodes determines the efficiency and where each key has to be unique



I hope this will clearify it.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ra Carter:
well... thanks for nothing since i already knew where the documentation was...



Remember that we can only know what you are telling us. The more you tell us about what you already know, and what you already tried, the more effectively we can answer your question.

It's typically not very effective to insult those who are spending their leisure time trying to help you.
 
Ra Carter
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the documentation did help... i was only joking with that comment but not really.. damn you people for not spoon feeding me answers!
reply
    Bookmark Topic Watch Topic
  • New Topic