如何让程序一直运行,很容易实现,只需要一直等待输出即可啦
本文链接:https://liuyanzhao.com/5312.html
- import java.util.Scanner;
- /*
- * @author LiuYanzhao
- */
- 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);
- }
- }
- }
本文链接:https://liuyanzhao.com/5312.html
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏