304迭代器模式 Peter2Peter2Peter 2022-10-29 33 阅读1分钟 定义 迭代器模式是一种行为设计模式,让你能在不暴露集合底层表现形式(列表,栈等)的情况下遍历集合中所有的元素。 类图 代码 public class IteratorPattern { public static void main(String[] args) { //数组 new ArrayList<>().iterator(); //链表 new LinkedList<>().iterator(); } }