解决:Scanner输入数字总是莫名其妙多个0
用BufferedInputStream解决
1 Scanner scanner = new Scanner(new BufferedInputStream(System.in)); 2 System.out.println("---Please input 3 integers like this: 1 2 3---"); 3 int count = 0; 4 int[] container = new int[3]; 5 while (scanner.hasNextInt()) { 6 container[count++] = scanner.nextInt(); 7 if (count == container.length) { 8 break; 9 } 10 }