Back to Multiple Choice Quiz
next vs nextLine
Java quiz · Question 16When the input is just hello on one line (nothing after it), what will be printed by this program?
Code
1import java.util.Scanner;23public class Main {4 public static void main(String[] args) {5 Scanner input = new Scanner(System.in);67 String first = input.next();8 String rest = input.nextLine();910 System.out.println("first=" + first);11 System.out.println("rest=" + rest);12 }13}