• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HashTables

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could someone give me an idea (in english) what a hashtable is and what I would use the HashTable class for? I have been programming in java for about a year, but I need to begin to understand more than "Hello World".
Thanks,
Gary
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Visit http://java.sun.com/products/jdk/1.1/docs/api/java.util.Hashtable.html
 
Gary Guion
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know where the API's are. I just wanted an example in laymans terms. Thanks, but do you have any examples etc.
Gary
 
Sheriff
Posts: 17648
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then perhaps you've haven't found this link to the Collections trail in the Java Tutorial yet:
http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html
 
Gary Guion
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gothrough the code. Definitely you will get what is hashtable and how to use it.
/*Hashtable is used to store and retrieve objects*/
import java.util.*;
class htable
{
public static void main(String args[])
{
Hashtable h=new Hashtable(); //Default constructor
int i=0;
String s[]={"Sun","MicroSoft","Bell"}; //object initialize
//storing the object in the hashtable.
h.put(s[0],"java");
h.put(s[1],"c#");
h.put(s[2],"c");

//getting the objects one by one
while(i<h.size())>
{
System.out.println(h.get(s[i]));
i++;
}
h.clear(); //clear the hashtable
} //end of main
}

The while loop condition is
i less than h.size()
If you want more information about hashtable mail me. I will give the details.
Email id: sanjaykumaresan@rediffmail.com
M.Sanjay

[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
[This message has been edited by sanjay kumaresan (edited July 01, 2001).]
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Respected Sir,
A HashTable is a class in the java.util package.If I am working on a Chat Application in Java,then I can make use of an Hashtable.
An Array has a fixed number of cells so if I want to add some new friends in my Chat list,then I can't do it by using an Array.But I can do the same by using a HashTable because I can expand as well as shrink the size of an HashTable.I can store the list of friends in it and can retrieve it accordingly.
That's exactly the use of an Hashtable.An HashTable is similar to a multi-dimensional array.It makes use of certain keys internally which points to the specific record in the HashTable.
There are certain classes like an Hashtable,StringTokenizer etc.in the java.util package that are used in Projects which are made in Advanced Java.
That is the point where exactly you can make use of these classes which are present in the java.util package.
regards,
Shalina.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic