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(); } } }
输入的字符不是回车就重新输入:
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(); } } }