I have this code that asks for a name and age in a do-while loop:
public class Test1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
do {
System.out.print("Enter name & age: ");
System.out.printf("%s %d",
scanner.next(), scanner.nextInt());
} while (scanner.hasNext());
}
}
It outputs:
Enter name & age: test 6
test 6
and then doesn't seem to react to my input, while it should have repeated the question on the third line. What is wrong here?