G
gast
Gast
Guten Abend,
ich habe mal ein Programm geschrieben, soweit stimmt eigentlich alles, nur wirft es mir eine Exception.
Ich hatte mit Exceptions noch nicht zu tun, deshalb weiß ich nicht wie ich sie behandel.
Kann mir bitte jmd. helfen
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Matrix_8.compute(Matrix_8.java:8)
at Matrix_8.main(Matrix_8.java:28)
ich habe mal ein Programm geschrieben, soweit stimmt eigentlich alles, nur wirft es mir eine Exception.
Ich hatte mit Exceptions noch nicht zu tun, deshalb weiß ich nicht wie ich sie behandel.
Kann mir bitte jmd. helfen
Code:
public class Matrix_8 {
public static void compute (double [][]A, double [][]B){
double [][]C= new double [8][8];
for (int i=0; i<A.length;i++){
for (int k=0; k<A.length;k++);{
for (int j=0;j<A.length;j++){
C[i][j]=A[i][j]-B[j][i]+2;
}
}
}
}
public static void main (String []args){
{
double [][]M1={ {2d,1d,0d,-1d},
{3d,2d,1d,0d},
{4d,3d,2d,1d,0d},
{5d,4d,3d,2d,1d,0d},
{6d,5d,4d,3d,2d,1d,0d},
{7d,6d,5d,4d,3d,2d,1d,0d},
{8d,7d,6d,5d,4d,3d,2d,1d},
{9d,8d,7d,6d,5d,4d,3d,2d},};
double [][]M2={ {-1d,-2d,-3d,-4d,-5d},
{-1d,-2d,-3d,-4d},
{-1d,-2d,-3d},
{-1d,-2d},
{-1d}};
Matrix_8.compute(M1,M2);
}
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Matrix_8.compute(Matrix_8.java:8)
at Matrix_8.main(Matrix_8.java:28)