File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes whats a hash map??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "whats a hash map???" Watch "whats a hash map???" New topic
Author

whats a hash map???

alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
i tried to read in google on it
but its so abscure

is it an array
is it a linked list
is it a stack??
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

It is a Map.

From the API for java.util.Map:
An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.


Then we need the concept of a hash function (from wikipedia):
(turns) some kind of data into a relatively small integer, that may serve as an index into an array. The values returned by a hash function are called hash values, hash codes, hash sums, or simply hashes.


In a Map we store values against a key. In a HashMap, the key is based on the hash code for the object passed in. This provides a faster way to write and retrieve objects from the associated Map.

There are a few tricks to HashMaps, such as efficient sizes and providing effective hashing values (by overriding the hashcode method on the Class), but that's a job for another day
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
ok i understood
we take some data put in in some cell in the map and in order
to use that data we need the key for it

so how do use this command
equals(Object o)

is it like whith objects t.equals(x);
because there could be many objects in the map "t"
i am puzzled

how do we exctract a certain data from a certain location??

i dont know how to understand the definition for this command
hashCode()-Returns the hash code value for this map ??
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
A Map is a bit like a telephone book. You put in a name and get out a number. If you put("donaldth smithts", 56789) it will record your phone number a 56789. If you write get("donaldth smithts") it will give 56789.
If you write put("donaldth smithts", 67890) it will change your phone number to 67890 and forget about 56789.
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
so how does this command go

equals(Object o)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
Like this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: whats a hash map???