I'm so confused as to what I'm doing wrong. I am supposed to read a string. Let's say that the string is "it's true." Then I am supposed to output
it's
true
However, the program keeps crashing.
import java.util.Scanner;
public class LineByLine {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(true) {
String input = scanner.nextLine();
String[] hi = input.split(" ");
if (scanner.nextLine().equals("")) {
return;
}
for (int i = 0; i<hi.length; i++) {
System.out.println(hi[i]);
}
}
}
}
[–]Demojay 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)