Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Daryl Butler   on Dec 14 In Java Category.

  
Question Answered By: May Hansen   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).

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Hashtable Or get search suggestion and latest updates.


Tagged: