摘要: Iterable接口 实现该接口的类,对象可以通过foreach方式遍历。 该接口中只定义了一个方法,返回iterator对象。 Iterator接口 这是一个用于遍历集合中元素的接口,主要包含hashNext(),next(),remove()三种方法。它的一个子接口LinkedIterator在它的基础上又添加了三种方法,分别是add(),previous(),hasPreviou... 阅读全文
posted @ 2016-09-11 21:36 流年素心 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 首先,Enumeration已经被Iterator取代了。。。。。 Enumeration是个接口,不是类,使用时需要具体的实现类。 里面只定义了两个方法: hasMoreElements()和nextElement()。 而Iterable接口将上述两个方法的命名缩短了,同时提供了remove()方法。 阅读全文
posted @ 2016-09-11 20:56 流年素心 阅读(241) 评论(0) 推荐(0) 编辑