I have a multidimensional array which I don’t know how to “call” in a specific index.
Here is my code :
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.
}
}
Before, the array was a long-type array and it worked well, but now that is a String-type array, it seems to doesn’t work the same way.
I have this error : Type mismatch: cannot convert from String to int
Syntax is wrong on both lines:
What do you expect the ++ to do in this case?
stats.get(j)[4]is accessing the 4th Element on the j-array in our list, which is a string array and your calling a mathimatical operator on the 4th element which is a string.