【学习心得】java实用编程100例

来源:互联网 发布:引用60分钟数据 编辑:程序博客网 时间:2024/06/06 07:49


哈希表的遍历:枚举类(Enumeration) 和 迭代器(Iterator)

1.使用枚举类遍历:

Hashtable table=new Hashtable();void test(){Enumeration ennu=table.elements();while(ennu.hasMoreElements()){System.out.println(ennu.nextElement());}}


2.使用迭代器遍历

Hashtable table=new Hashtable();void test(){Collection constr=table.entrySet();Iterator intr=constr.iterator();while(intr.hasNext()){System.out.println(intr.next());}}


0 0