博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java如何让程序一直运行,不停止
阅读量:85 次
发布时间:2019-02-26

本文共 537 字,大约阅读时间需要 1 分钟。

如何让程序一直运行,很容易实现,只需要一直等待输出即可啦

  1. import java.util.Scanner;
  2. /*
  3.  * @author LiuYanzhao
  4.  */
  5. public class Test {
  6.     private static final String OPERATION_EXIT = "EXIT";
  7.     public static void main(String[] args) {
  8.         System.out.println("请开始您的输入,EXIT/E 退出");
  9.         //怎么让程序一直运行
  10.         Scanner scan = new Scanner(System.in);
  11.         while(scan.hasNext()) {
  12.             String in = scan.next().toString();
  13.             if(OPERATION_EXIT.equals(in.toUpperCase())
  14.                     || OPERATION_EXIT.substring(01).equals(in.toUpperCase())) {
  15.                 System.out.println("您成功已退出!");
  16.                 break;
  17.             }
  18.             System.out.println("您输入的值:"+in);
  19.         }
  20.     }
  21. }

本文链接:

转载地址:http://mpuu.baihongyu.com/

你可能感兴趣的文章