Several inputs in order
Each call to nextLine() reads the next line of input, so a program can read as many lines as it needs, one after another. They're read in order: the first nextLine() gets the first line, the second gets the second, and so on. The program waits at each nextLine() until a line is there.
Scanner scanner = new Scanner(System.in);
System.out.println("First word?");
String first = scanner.nextLine();
System.out.println("Second word?");
String second = scanner.nextLine();
System.out.println(second + " " + first);
world
helloFirst word?
Second word?
hello worldThe variables keep their values, so the program can print them in any order and as often as it likes. Only the reading has to follow the order of the input.
If a program asks for more lines than the input has, it stops with an error: NoSuchElementException: No line found. When that happens on this site, the result explains it. It usually means the program reads one line too many.