java.util.Hashtable.elements()方法


java.util.Hashtable.elements()方法

package com.codingdict;

import java.util.*;

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

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

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

      // create enumeration
      Enumeration e = htable.elements();

      System.out.println("Display result:");

      // display search result
      while (e.hasMoreElements()) {
         System.out.println(e.nextElement());
      }      
   }    
}