1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners
View Answers

September 11, 2008 at 6:17 PM

Hi ,

A hash-table is a data-structure that consists of an array of linked lists.

The beauty of this arrangement is that you can have the speed of array-access, along with the convenience of inserting objects into linked lists. What's more, inserting and searching through a hash-table is very, very fast.

import java.util.*;
import java.util.Hashtable;

public class HashTableTest {

public static void main(String args[]){
System.out.println("welcome to Roseindia");
Hashtable hash = new Hashtable();

hash.put("vinod", "vinod");
hash.put(hash, hash);

System.out.println("Display list : " + hash);

catch(Exception e){
System.out.println("error in table:" + e.getMessage());


import java.util.*;

public class StackExample {
public static void vectorShow ( Vector v ) {
System.out.println ( "printing vector contents" ) ;
for ( int i = 0, length = v.size ( ) ; i < length; i++ )
System.out.println ( v.get ( i ) ) ;
public static void main ( String [ ] args ) {
Stack<String> stack = new Stack<String>( ) ;
//Treat as a Stack
stack.push ("welcome") ;
System.out.println(stack.pop ( ) ) ;
//Treat as a vector
stack.add ( "1" ) ;
stack.add ( "2" ) ;
stack.add ( "3" ) ;
System.out.println ( stack.get ( 2 ) ) ;
System.out.println ( stack.contains ( "1" ) ) ;
stack.insertElementAt ( "5", 1 ) ;
stack.removeElementAt ( 2 ) ;
vectorShow(stack) ;

import java.util.*;

public class QueueList {
public static void main(String[] args) {
Queue<String> queue = new LinkedList<String>();

System.out.println("Size of list: " + queue.size());
System.out.println("Queue head using peek : " + queue.peek());
System.out.println("Queue head using element: " + queue.element());
Object data;
while ((data = queue.poll()) != null) {


Visit for more information.



Related Tutorials/Questions & Answers:
Java hashtable
Java hashtable   What is hash-collision in Hashtable and how it is handled in Java
Differences between HashMap and Hashtable?
Differences between HashMap and Hashtable?  Differences between HashMap and Hashtable
Java hashmap, hashtable
Java hashmap, hashtable  When are you using hashmap and hashtable
hashtable java swing
hashtable java swing  i m getting this warning code is here Hashtable nu=new Hashtable(); Hashtable ns=new Hashtable(); nu.put(new... mber of the raw type Hashtable plz help me
Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value... { public static void main(String [] args){ Map map = new Hashtable
The Hashtable Class
The Hashtable Class In this section, you will learn about Hashtable and its implementation with the help of example. Hashtable is integrated... it also stores key/value pair in Hashtable. But the difference is Hashtable
How to find hashtable size in Java?
How to find hashtable size in Java?  Hi, What is the code for Hashtable in Java? How to find hashtable size in Java? Give me the easy code. Thanks
hashtable - Java Beginners
hashtable  pls what is a hashtable in java and how can we use it to compine queue and stacks. thnks in advance.  Hi , A hash-table... to Roseindia"); Hashtable hash = new Hashtable(); hash.put("amar","amar"); hash.put
Doubts regarding Hashtable - Java Beginners
Doubts regarding Hashtable  Hi, I am new to hashtable.Is it possible to create a hashtable like this? java.util.Hashtable hashtable=new...(12,13,10,1)); since we get the key of hashtable from the database. When I tried
Java Collection : Hashtable
Java Collection : Hashtable In this tutorial, we are going to discuss one of concept (Hashtable ) of Collection framework. Hashtable  : Hashtable.... When you increase the entries in the Hashtable, the product of the load
Java Hashtable Iterator
be traversed by the Iterator. Java Hashtable Iterator Example import java.util.*; public class hashtable { public static void main(String[] args) { Hashtable hastab = new Hashtable(); hastab.put("a", "andrews
J2ME HashTable Example
J2ME HashTable Example       To use the HashTable, java.util.Hashtable package must be imported into the application. Generally HashTable are used to map the keys to values
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a hashtable with some student hall ticket numbers and their results. when we type a hallticket number,it shud display the results? please provide the detail java code for this? thanks in advance
Hashtable java prog - Java Interview Questions
Hashtable java prog  Create a Hashtable with some students hall ticket numbers and their results. when you type a hall tickets number,it shud display... bal; Hashtable table = new Hashtable(); table.put( new Integer(1111),"Selected
Create JTree using an Object
object that works with Hashtable.  Program Description:  This program... the init() method that uses a Hashtable object to store data .This object is added...;void init(){   Hashtable hash = new Hashtable
Break a Line for text layout
is used. The class Hashtable maps keys to values. A string is defined...;new Hashtable();      private static 
Media MIDlet Example
created an 'item' object for Hashtable and put all 'wav' file in this table...;items = new Hashtable();   itemsInfo = new Hashtable();   items.put("Kyo Aage-Piche Dolte 
Collections in Java
, LinkedList, Stack and Hashtable. Collections is a group of objects. Objects can
HashMap in Java
HashMap class is used to implement Map interface. The value of HashMap is stored using get() and put(). HashMap provides key-value access to data. HashMap is almost equal to HashTable, the only difference is that HashMap allows null
difference  difference between hashtable and hashtree
spring - Spring
spring  what is the use of HashTable concept in spring
Collections - Java Interview Questions
Collections  By default, Hashtable is unordered. Then, how can you retrieve Hashtable elements in the same order as they are put inside
java - Java Beginners
Java hashtable null values  How to get if there is null value in the Java hashtable? and is it possible to accept both null and values
java  What is the super class of Hashtable?  The Dictionary class is the abstract parent Hashtable
Java Collection
Java Collection  What are Vector, Hashtable, LinkedList and Enumeration
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections
Collections Framework
Collections Framework  Sir, We know that both HashMap & Hashtable.... But there is some difference between this two class that are 1)Hashtable is synchronized but HashMap not. 2)Hashtable doesn't contain null but HashMap can. My question
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections and Collection
hashcode() and equals() - Java Interview Questions
hashcode() and equals()  can you give one hashtable prog using equals() and hashcode()?PLease..thanks in advance
Map  Hi how can we retrieve key - value pair from hashtable and hashmap? how can we retrieve arraylist element? Thanks Kalins Naik   Please visit the following links: HashTable Example ArrayList Example HashMAp