我有一個多維數組,我不知道如何在特定索引中「調用」。如何在Java中調用多維數組的索引
這裏是我的代碼:
List<String[]> stats = new ArrayList<>();
stats.add(new String[11]);
String currentDate = null;
String nextDate = null;
String prize = null;
int j = 0;
for(i = 1; i < statsFromFile.size(); i++) {
currentDate = toStringDate(statsFromFile.get(i).get(0), date, sdf);
nextDate = toStringDate(statsFromFile.get(i+1).get(0), date, sdf);
prize = statsFromFile.get(i).get(1);
stats.get(j)[0] = currentDate;
if(currentDate.equals(nextDate)) {
stats.get(j)[4]++; // Here's the problematic line.
}
else {
stats.add(new String[11]);
j++;
prize = statsFromFile.get(j).get(0);
stats.get(j)[1]++; // And here too.
}
}
,前陣是一個長期類型的數組和它的工作很好,但現在是一個String類型的數組,它似乎不起作用相同辦法。
我有這樣的錯誤:在兩條線上Type mismatch: cannot convert from String to int
什麼是statsFromFile? – CloudyMarble
另一個帶有String數據的數組。當然,Rhaa dammit, – Emilie