从控制台读取数据出错,求助
程序代码:
for(int i = 0;i < N;i ++){ sch[i].studentName = reader.next(); sch[i].finalScore = reader.nextInt(); sch[i].compareScore = reader.nextInt(); sch[i].studentCadre = reader.nextByte(); sch[i].westStudent =reader.nextByte(); sch[i].numberOfPaper = reader.nextInt(); }
使用这样的读取数据时总是在运行时抛出异常,是不是因为中间的空格有影响??应该怎么处理啊?
输入学生数目:
2
ww 89 78 Y Y 1 //是这中间的空格有影响么???
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at scholarship.main(scholarship.java:42)