提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
中断并继续您的for循环
//N o w J a v a . c o m public class Main { public static void main(String[] args) { for (int number = 2; number <=20; number += 2) { if (number == 12) break; System.out.print(number + " "); } System.out.println(); } }