new Hashtable() : Hashtable « java.util « Java by API






new Hashtable()

  
/*
 * Output:
 * 

a: a
b: 2.0
c: b
d: 30


 * 
 *  
 */

import java.util.Dictionary;
import java.util.Hashtable;

public class MainClass {
  public static void main(String args[]) {
    Hashtable ht = new Hashtable();
    ht.put("a", "a");
    ht.put("b", new Double(2));
    ht.put("c", "b");
    ht.put("d", new Integer(30));
    show(ht);
  }

  static void show(Dictionary d) {
    System.out.println("a: " + d.get("a"));
    System.out.println("b: " + d.get("b"));
    System.out.println("c: " + d.get("c"));
    System.out.println("d: " + d.get("d"));
  }
}


           
         
    
  








Related examples in the same category

1.new Hashtable < K, V > ()
2.Hashtable: clear()
3.Hashtable: clone()
4.Hashtable: contains(Object value)
5.Hashtable: containsKey(Object key)
6.Hashtable: elements()
7.Hashtable: entrySet()
8.Hashtable: get(E e)
9.Hashtable: isEmpty()
10.Hashtable: iterator()
11.Hashtable: keySet()
12.Hashtable: keys()
13.Hashtable: put(K key, V value)
14.Hashtable: putAll(Map t)
15.Hashtable: remove(Object key)
16.Hashtable: size()
17.Hashtable: values()