我试图将以下行保存到不同的数组中:
1908,Souths,Easts,Souths,Cumberland,Y,14,12,4000
我使用的代码给了我整数值,year[i]
但给了我零值winningScore[i]
,loosingScore[i]
和crowd[i]
。任何人都可以帮助我吗?我的代码如下:
str[i] = inputFile.nextLine();
StringTokenizer tok = new StringTokenizer(str[i], ",");
while (tok.hasMoreTokens()) {
year[i] = Integer.parseInt (tok.nextToken());
winteam[i] = tok.nextToken();
loosingteam[i] = tok.nextToken();
minor[i] = tok.nextToken();
wooden[i] = tok.nextToken();
held[i] = tok.nextToken();
if(held[i] == "Y") {
winningScore[i] = Integer.parseInt (tok.nextToken());
loosingScore[i] = Integer.parseInt (tok.nextToken());
crowd[i] = Integer.parseInt (tok.nextToken());
}
else {
break;
}
}