Whats the difference between Hash and Map ?

E

exquisitus

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

MTIA
 
E

Eric Sosman

exquisitus said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top