This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Hashtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hashtable" Watch "Hashtable" New topic
Author

Hashtable

Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
what Hashtable class is for in java?
I look in API, but I still have confusion
Thanks,
Angela
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
Think of a hashtable as a special kind of database table with two columns. When you create the table, you don't have to specify the data types of these columns. The first column is the ID or Key column, the second is the actual object ( or rest of the record, if you will ).
Just like you can do a Select * where ID = XX in an Relational database table, you can do a get() on a hastable. You pass the ID value to the get method. It returns an Object which you can then cast to the real type of the object.
You can look at the methods such as
values (), keyset(), entryset() and put() roughly along the following lines.
values() - return the second column from all the rows of the table
keyset() return the ID column from all the rows of the table
entryset() return both the columns from all the rows
put() insert a record with the given values for the two columns and so on.
Remember this is just an anology to help you understand how hashtable can be used.
HTH
Angela D'souza
Ranch Hand

Joined: Jan 16, 2002
Posts: 469
Thanks a lot Shivaji,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hashtable
 
Similar Threads
I defined an equals method, but Hashtable ignores it. Why?
Collections.synchronizedMap or thread safe classes in collection which one is better?
Hashtable casting error
Passing my object to one to other activity
Reg: HashMap