Ai
5 Star 36 Fork 25

随心/ProjectStudy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Main.java 641 Bytes
一键复制 编辑 原始数据 按行查看 历史
随心 提交于 2023-02-03 10:00 +08:00 . 设计模式-迭代器模式,解释器模式
package com.design.iterator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/**
* 迭代器模式 - JDK的容器的Iterator
* 有兴趣可以研究源码,自己实现
*
* @author wliduo[i@dolyw.com]
* @date 2023/2/2 16:22
*/
public class Main {
public static void main(String[] args) {
Collection collection = new ArrayList();
for (int i = 0; i < 10; i++) {
collection.add(new String("s" + i));
}
// 遍历
Iterator it = collection.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/dolyw/ProjectStudy.git
git@gitee.com:dolyw/ProjectStudy.git
dolyw
ProjectStudy
ProjectStudy
master

搜索帮助