Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Hashtable

  Asked By: Daryl    Date: Dec 14    Category: Java    Views: 458
  

i am new to java.And i don't know about Hashtable. what is it used for? what is
hash code?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: May Hansen     Answered On: Dec 14

> i am new to java.And i don't know about Hashtable. what is it used for?
> what is hash code? please help me !!

hashtable  is essentially a what the Map from the java  Collections
Framwork was based from. Actually it is a left over from when they took
ideas from C/C++.

The way a Hashtable works is that you reference a object with some sort
of key. So I could make a hashtable link the String "PlayerOne" to -> a
particular Player Object.

In other words Hashtable is a datastructure that stores a bunch of
objects that are located via a key.

if you (if hashtables add instead of put forgive me :P)
hashTable.put("one", someObjectRefference);
hashTable.put("two", someOtherObjectRefference);

You could
hashTable.get("one"); would return the Object that was referenced in the
first put.

For all intents and purposes you only need to know that hashcode is the
code that the JVM uses to decide if two items are the same thing. This
isn't the entire (or entirely correct) answer, but when you actually
have some sort of need to know more you will probably have the skills to
work it out.

Hashtabls use this code  to make sure that you are putting different
Objects in different places and keeping record of it. Be warned that it
is possible (although remote) that two different objects can hash to the
same hash code (although it isn't likely).

 
Answer #2    Answered By: Abana Cohen     Answered On: Dec 14
 
Didn't find what you were looking for? Find more on Hashtable Or get search suggestion and latest updates.




Tagged: