集册 Java实例教程 使用continue语句跳过数字12,而不是在数字达到12时完全停止计数:

使用continue语句跳过数字12,而不是在数字达到12时完全停止计数:

欢马劈雪     最近更新时间:2020-01-02 10:19:05

426
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用continue语句跳过数字12,而不是在数字达到12时完全停止计数:

public class Main

{

  public static void main(String[] args)

  {
  /** 
  来 自 
  NowJava.com
  **/

    int number = 0;

    while (number < 20)

    {

      number += 2;

      if (number == 12)

        continue;

      System.out.print(number + " ");

    }

    System.out.println();

  }

}