本文共 537 字,大约阅读时间需要 1 分钟。
如何让程序一直运行,很容易实现,只需要一直等待输出即可啦
- import java.util.Scanner;
- public class Test {
- private static final String OPERATION_EXIT = "EXIT";
- public static void main(String[] args) {
- System.out.println("请开始您的输入,EXIT/E 退出");
-
- Scanner scan = new Scanner(System.in);
- while(scan.hasNext()) {
- String in = scan.next().toString();
- if(OPERATION_EXIT.equals(in.toUpperCase())
- || OPERATION_EXIT.substring(0, 1).equals(in.toUpperCase())) {
- System.out.println("您成功已退出!");
- break;
- }
- System.out.println("您输入的值:"+in);
- }
- }
- }
本文链接:
转载地址:http://mpuu.baihongyu.com/