提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
获取哈希表中包含的值的集合
import java.util.Enumeration;/** nowjava.com - 时代Java 提 供 **/ import java.util.Iterator; import java.util.Hashtable; import java.util.Collection; public class Main { public static void main(String[] args) { Hashtable ht = new Hashtable(); //add key value pairs to Hashtable ht.put("1","One"); ht.put("2","Two"); ht.put("3","Three"); Collection c = ht.values(); System.out.println("Values of Collection created from Hashtable are :"); Iterator itr = c.iterator(); while(itr.hasNext()) System.out.println(itr.next()); /* *来 自 N o w J a v a . c o m */ c.remove("One"); System.out.println(