博客
关于我
Java如何让程序一直运行,不停止
阅读量:88 次
发布时间: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/

你可能感兴趣的文章
Nginx 常用配置清单
查看>>
nginx 常用配置记录
查看>>
nginx 开启ssl模块 [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx
查看>>
Nginx 我们必须知道的那些事
查看>>
Nginx 源码完全注释(11)ngx_spinlock
查看>>
Nginx 的 proxy_pass 使用简介
查看>>
Nginx 的优化思路,并解析网站防盗链
查看>>
Nginx 的配置文件中的 keepalive 介绍
查看>>
Nginx 结合 consul 实现动态负载均衡
查看>>
Nginx 负载均衡与权重配置解析
查看>>
Nginx 负载均衡详解
查看>>
nginx 配置 单页面应用的解决方案
查看>>
nginx 配置https(一)—— 自签名证书
查看>>
nginx 配置~~~本身就是一个静态资源的服务器
查看>>
Nginx 配置服务器文件上传与下载
查看>>
Nginx 配置清单(一篇够用)
查看>>
Nginx 配置解析:从基础到高级应用指南
查看>>
nginx 集群配置方式 静态文件处理
查看>>
nginx+php的搭建
查看>>
nginx+tomcat+memcached
查看>>