Java如何让程序一直运行,不停止
如何让程序一直运行,很容易实现,只需要一直等待输出即可啦
- 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);
- }
- }
- }