解决: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 }

 

posted @ 2014-01-08 15:17  rldts  阅读(345)  评论(0编辑  收藏  举报