你们写JAVA的时候,用nextLine是如何实现在while里的第二次调用的呢。nextLine

2025-06-22 16:46:27
推荐回答(3个)
回答1:

不知道你想表达什么,请贴出代码
nextLine()方法返回的是enter键之前的字符
Scanner line = new Scanner(System.in);
String lineStr = line.nextLine();
String lines = line.nextLine();
想用两次就直接掉用两次,把nextLine赋值给字符串

回答2:

不是特别需要的话,可以使用next试一试。

回答3:

你写2个
nextLine
不就好了吗?