提供了外部访问集合的方法,而又不暴漏元素内部细节
Interface Iterator{//迭代器接口
object next();
boolean remove();
boolean hasNext();
}
public class Collection{//被迭代和观察的集合
IteratorClas[] obs;
get Iterator(){
return new
}
public class IteratorClas{//被观察的对象
do();
}
public class ConcretIterato implements Iterator{//具体迭代器实现
Collection collection ;
private int index;
public ConcretIterato(Collection c){
collection = c;
}
public object next(){
return c[++index];
}
public boolean hasNext()}
return indext== c.length;
}
public looean remove{
}