提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
继续语句终止for语句的迭代
public class Main /* 来 自* 时代Java公众号 - N o w J a v a . c o m */ { public static void main(String[] args) { for (int count = 1; count <= 10; count++) // loop 10 times { if (count == 5) continue; // skip remaining code in loop body if count is 5 System.out.printf("%d ", count); } System.out.printf("%nUsed continue to skip printing 5%n");/**来 自 NowJava.com**/ } }