Hashtable: put(K key, V value) : Hashtable « java.util « Java by API






Hashtable: put(K key, V value)

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