I have this code:
public int[] KonversiIndexBM (int[] Individu) throws SQLException {
int StringLenChromosome = Individu.length;
ResultSet rs;
int[] IndexBM = new int[StringLenChromosome];
for (int j = 0; j < StringLenChromosome; j = j + 8) {
IndexBM[j] = (int) Math.round(((this.CountRow(conn, "karbohidrt") - 1) * ((double) (Individu[j] - 1) / (55 - 1))) + 1);
IndexBM[j + 1] = (int) Math.round((this.CountRow(conn, "protein_hewani") - 1) * ((double) (Individu[j + 1] - 1) / (55 - 1)) + 1);
IndexBM[j + 2] = (int) Math.round((this.CountRow(conn, "protein_nabati") - 1) * ((double) (Individu[j + 2] - 1) / (55 - 1)) + 1);
//IndexBM[j + 3] = (int) Math.round((this.CountRow(conn, "sayurana") - 1) * ((double) (Individu[j + 3] - 1) / (55 - 1)) + 1);
IndexBM[j + 3] = (int) Math.round((this.CountRow(conn, "sayuranb") - 1) * ((double) (Individu[j + 3] - 1) / (55 - 1)) + 1);
IndexBM[j + 4] = (int) Math.round((this.CountRow(conn, "buah") - 1) * ((double) (Individu[j + 4] - 1) / (55 - 1)) + 1);
IndexBM[j + 5] = (int) Math.round((this.CountRow(conn, "lemak") - 1) * ((double) (Individu[j + 5] - 1) / (55 - 1)) + 1);
IndexBM[j + 6] = (int) Math.round((this.CountRow(conn, "gula") - 1) * ((double) (Individu[j + 6] - 1) / (55 - 1)) + 1);
IndexBM[j + 7] = (int) Math.round((this.CountRow(conn, "susu") - 1) * ((double) (Individu[j + 7] - 1) / (55 - 1)) + 1);
}
return IndexBM;
}
`
And the error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 189
The Line which Causes error is:
IndexBM[j + 5] = (int) Math.round((this.CountRow(conn, "lemak") - 1) * ((double) (Individu[j + 5] - 1) / (55 - 1)) + 1);
I don't know why this is wrong. What should I do?