1

Why is this popping up?

Syntax error on token "+", Expression expected after this token

for (int row = 0; row < data.length; row++) {
  for (int col = 7;;) {
            data[row][col] = [row][1] + [row][2] + [row][3] + [row][4] + [row][5] + [row][6];
    }for (int col = 8;;) {
            data[row][col] = formatter.format(([row][7] / 2650) * 100);
   }
}

It appears on every plus sign and the equals after data[row][col] =.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137

1 Answers1

0

The [row][col] is an access expression for the array, so you need to specify what array you want to access on these indices. Therefore every of your statements with indices should start with data

for (int row = 0; row < data.length; row++) {
    for (int col = 7;;) {
        data[row][col] = data[row][7] + data[row][2] + data[row][3] + data[row][4] + data[row][5] + data[row][6];
    }
    for (int col = 8;;) {
        data[row][col] = formatter.format((data[row][7] / 2650) * 100);
    }
}

For more information and examples see Java Tutorial on Arrays.

Also notice that you have two infinite loops, I guess the code is incomplete or the loops are redundant

for (int row = 0; row < data.length; row++) {
    data[row][7] = data[row][1] + data[row][2] + data[row][3] + data[row][4] + data[row][5] + data[row][6];
    data[row][8] = formatter.format((data[row][7] / 2650) * 100);
}
Nikolay K
  • 3,770
  • 3
  • 25
  • 37