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);
- }
- }
- }
- 微信
- 赶快加我聊天吧
- 博客交流群
- 海纳百川,大家来水
2017年10月10日 11:44:28 1楼
评论测试
2017年10月10日 11:44:36 1层
@ 言曌 再次测试