Scanner的next和nextLine区别
只要内容中含 空格,next就会中断读取
eg: Scanner sc = new Scanner(System.in);
if (sc.hasNext()) {String str = sc.next(); System.out.println("输出内容为: " + str);}
如果输入为: Hello World
那么输出为: Hello
if (sc.hasNextLine()) {String str = sc.nextLine(); System.out.println("输出内容为: " + str);}
如果输入为: Hello World
那么输出为: Hello World
并且nextLine()支持接收空白

浙公网安备 33010602011771号