1

I am trying to read Integer value after I hit space but using scanner it only works after I press Enter. How can I make it read the integers after the white space?

This is my code:

for (i = 0; i< n; i++) {
    scanner = new Scanner(System.in);
    list.add(scanner.nextInt());
}
Juan Carlos Mendoza
  • 5,736
  • 7
  • 25
  • 50
Marcos Guimaraes
  • 1,243
  • 4
  • 27
  • 50

1 Answers1

0

You cannot, it works that way System.in works that way, that buffer is flushed only upon pressing enter.

Antoniossss
  • 31,590
  • 6
  • 57
  • 99