zoukankan      html  css  js  c++  java
  • java基础--for-跑步运动

    for的死循环的运用

    注意:遇到break ;跳出整个for循环

     1 package Cforth;
     2 
     3 import java.util.*;
     4 
     5 public class C4_16 {
     6     public static void main(String[] args) {
     7         Scanner in = new Scanner(System.in);
     8         for (;;) {
     9             System.out.println("还跑吗");
    10             String flag = in.next();
    11             if (flag.equals("yes") || flag.equals("YES")) {
    12                 System.out.println("那你继续跑吧");
    13             } else {
    14                 System.out.println("停止");
    15                 break;
    16             }
    17         }
    18 
    19     }
    20 }

    测试结果:

    测试成功!

  • 相关阅读:
    optparse--强大的命令行参数处理包
    B/S和C/S架构的区别
    Document
    Document
    Document
    Document
    Document
    Document
    Document
    Document
  • 原文地址:https://www.cnblogs.com/Catherinezhilin/p/8398391.html
Copyright © 2011-2022 走看看