纠正for循环中关键字continue的执行顺序
时间:2014-05-03 00:03:21
收藏:0
阅读:311
下面是一个小程序,可以很好阐述 关键字:continue,break;
package org.song.loop;
public class TestLoop {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int total = 0;
for (int i = 0; i < 10; i++) {
if (i==1) {
continue;
}
if (i==2) {
break;
}
total += i;
}
System.out.println(total);
}
}
总结:continue 为执行下一次循环。
一切从发现纠正错误开始!
评论(0)