I have this code:
public class SimpleTest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter: ");
String s = "";
while (scanner.hasNext()) {
s += scanner.next();
System.out.println(s);
}
System.out.println("Result: " + s);
}
}
My code shows:
While Result:
line never gets printed.
How do I fix it? (Without using scanner.nextLine
, .split()
or a different while
condition like whle (!input.equals("quit"))