Supportnet Computer
Planet of Tech

Supportnet / Forum / Anwendungen(Java,C++...)

java applet -> java.lang.ArrayIndexOutOfBoundsException





Frage

Beim ausführen dieses Codes tritt eine java.lang.ArrayIndexOutOfBoundsException auf. das array matrix hat dimensionen von 100x100, matrix_x_dimensin und matrix_y_dimension sind beide 30. was kann da schiefgelaufen sein?? mfg [code]public void matrix_generate() { int current_position_active_cells; int i1, i2; for(i1 = 0; i1 < matrix_x_dimension; i1++) { for(i2 = 0; i2 < matrix_y_dimension; i2++) { current_position_active_cells = 0; if(matrix[i1 - 1][i2 - 1] == 1){current_position_active_cells += 1;} if(matrix[i1 - 0][i2 - 1] == 1){current_position_active_cells += 1;} if(matrix[i1 + 1][i2 - 1] == 1){current_position_active_cells += 1;} if(matrix[i1 - 1][i2 - 0] == 1){current_position_active_cells += 1;} if(matrix[i1 + 1][i2 - 0] == 1){current_position_active_cells += 1;} if(matrix[i1 - 1][i2 + 1] == 1){current_position_active_cells += 1;} if(matrix[i1 - 0][i2 + 1] == 1){current_position_active_cells += 1;} if(matrix[i1 + 1][i2 + 1] == 1){current_position_active_cells += 1;} //... } }[/code]

Antwort 1 von some1unknown

problem gelöst: i1/i2 können -1 werden

Ich möchte kostenlos eine Frage an die Mitglieder stellen:


Ähnliche Themen:


Suche in allen vorhandenen Beiträgen: