不用key值遍历HashTable
主要是keys()的用法。
public abstract Enumeration<K> keys()
- 返回此 dictionary 中的键的枚举。键方法的常规协定是返回 Enumeration 对象,该对象将生成此 dictionary 包含条目的所有键。
-
- 返回:
- 此 dictionary 中键的枚举。
- 另请参见:
elements()
,
Enumeration
Hashtable Htable;
Enumeration key = Htable.keys(); while (key.hasMoreElements()) { stu[m] = (Student)Htable.get(key.nextElement()); JOptionPane.showMessageDialog(null,stu[m].getName(), "提示", JOptionPane.INFORMATION_MESSAGE); m++; }