- 2
- 0
- 约1.18万字
- 约 45页
- 2016-12-08 发布于江苏
- 举报
迭代器模式的类图 迭代器模式的例子 Iterator public interface Iterator {? Object next(); void first(); void last(); boolean hasNext(); } 迭代器模式的例子 ConcreteIterator public class IteratorImpl implements Iterator {? private List list; private int index; //注意这个list,要想遍历一个集合,至少我们需要这个集合的引用,这是必须的,除非你想在浩瀚的内存中自己去锁定这个引用! public IteratorImpl(List list) { index = 0; this.list = list; } public void first() { index = 0; }? public void last() { index = list.getSize(); }? public Object next() {Object obj = li
原创力文档

文档评论(0)