java.util.Hashtable.clone()方法


java.util.Hashtable.clone()方法

package com.codingdict;

import java.util.*;

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

      // create two hash tables
      Hashtable htable = new Hashtable();
      Hashtable htableclone = new Hashtable();

      // put values into the table
      htable.put(1, "A");
      htable.put(2, "B");
      htable.put(3, "C");
      htable.put(4, "D");

      // check table content
      System.out.println("Original hash table content: "+htable);

      // clone hash table
      htableclone = (Hashtable)htable.clone();

      // check content after clone
      System.out.println("Clone table content: "+htableclone);      
   }    
}