I have the following code:
Scanner in = new Scanner (System.in);
String[] data = new String[5];
System.out.println(\"Please, enter the name of the customer orde
Don't use next()
and nextLine()
together if you don't know what you're doing, it easily results in errors. next()
reads the next input token, nextLine()
all tokens until next line. So if you have inputs like this:
John\nSquirrels
(\n is newline character)
The first next()
returns "John" and leaves us
\nSquirrels
After which a nextLine()
is facing no tokens before the end of the line, so you get an empty String instead of "Squirrels".