java.util.Hashtable.put() 方法


java.util.Hashtable.put() 方法

package com.codingdict;

import java.util.*;

public class HashTableDemo {
   public static void main(String args[]) {

      // create hash table
      Hashtable htable1 = new Hashtable();      

      // put values in table
      htable1.put(1, "A");
      htable1.put(2, "B");
      htable1.put(3, "C");
      htable1.put(4, "D");

      System.out.println("Initial hash table value: "+htable1);

      // put value at key 4
      String returnval = (String)htable1.put(4,"TP");

      System.out.println("Return value: "+returnval);
      System.out.println("New hash table value: "+htable1);
   }    
}