for & while &迭代器
for (int i = 0; i < 10; i++) { System.out.println("hello"); } int a=100; for (;a<110;a++) { System.out.println("hello"); } for(;;) //无限循环 相当于while(true) { System.out.println("A"); } //多变量 int count=5; for(int i=0,j=0;i<count;i++,j+=2) { System.out.println("i="+i+"j="+j); }
while可以一次不执行;
do{}while(循环条件) 至少执行一次;

int count=5; do{ System.out.println("do while"); count--; }while(count>1); while (count>1) { count--; System.out.println("aaa"); }
continue与break后,在方法内
return后,跳出方法
迭代器

private static HashMap<String, ServerConnectClientThread> hm = new HashMap<>(); Iterator<String> iterator = hm.keySet().iterator(); String onlineUserList = ""; while (iterator.hasNext()) { onlineUserList += iterator.next().toString() + " "; }
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术