java 空语句

输入的字符不是回车就重新输入:

import java.io.IOException;

public class HelloWorld {
    public static void main(String[] args) {
        try {
            while ((char)(System.in.read()) != '\n') {
                ;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }    
    }
}

 

posted @ 2016-08-18 18:01  zhuangrunwei  阅读(838)  评论(0编辑  收藏  举报