Whats the difference between Hash and Map ?

Discussion in 'Java' started by exquisitus, May 4, 2005.

  1. exquisitus

    exquisitus Guest

    As the subject says - anyone kind nough to summarise pros and cons. I
    have already Googled and not come up with anything useful.

    MTIA
     
    exquisitus, May 4, 2005
    #1
    1. Advertising

  2. exquisitus

    Eric Sosman Guest

    exquisitus wrote:
    > As the subject says -


    Not a good place to put your question: use Subject as
    a label for a complete message, not as a fragment of the
    message. (Somebody once made this point rather nicely by
    replying "See headers for answer," and putting the answer
    itself in the reply's headers instead of in its body.)

    > anyone kind nough to summarise pros and cons. I
    > have already Googled and not come up with anything useful.


    java.util.Map is an interface: a specification of
    certain methods that must be provided in any class that
    implements Map. The intent is that a class implementing
    Map should offer a service that associates "keys" with
    "values," and the methods specified by Map provide the
    means to form and remove key/value pairs, to determine
    the value corresponding to a given key, to list all the
    keys and/or all the values, and so on.

    Java (as of 1.4, anyhow) has no class or interface
    named "Hash." It does have java.util.HashMap (a class
    that implements Map, using hashing techniques to manage
    the key/value associations), java.util.HashTable (a sort
    of "evolutionary predecessor" of HashMap, similar in
    intent but different in detail), and java.util.HashSet
    (a class that implements the java.util.Set interface,
    using a HashMap to store the elements contained in the
    Set). Java also offers assorted special-purpose classes
    like javax.print.attribute.HashAttributeSet, that use
    hashing techniques internally.

    Pros and cons? Impossible to say, really, without
    some context. What are the pros and cons of a hammer
    as opposed to a coping saw? It all depends on what
    you're trying to do.

    --
     
    Eric Sosman, May 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper
    Replies:
    2
    Views:
    3,783
    Showjumper
    Jan 20, 2004
  2. jakk
    Replies:
    4
    Views:
    12,511
  3. navS
    Replies:
    3
    Views:
    535
    Ismo Salonen
    May 9, 2008
  4. rp
    Replies:
    1
    Views:
    562
    red floyd
    Nov 10, 2011
  5. Justin C
    Replies:
    1
    Views:
    198
    Justin C
    Oct 7, 2013
Loading...

Share This Page