I was trying to do a sorting class of matrices entries and I first put them into an array
double[][] A ={{0,70,9},{1,3,4}};
double[] vektori_per_sortim=new double[A.length*A[0].length];
int k=0;
for(int i=0; i!=A.length; i++)
{
for(int j=0; j!=A[0].length; j++)
{
vektori_per_sortim[k]=A[i][j];
k++;
}
}
and then I tried to put them into the matrices again
int r=0;
while(r!=vektori_per_sortim.length)
{
for(int i=0; i!=vektori_per_sortim.length/A.length; i++)
{
for(int j=0; j!=vektori_per_sortim.length/A[0].length; j++)
{
A[i][j]=vektori_per_sortim[r];
r++;
}
}
}
but I get an error java.lang.ArrayIndexOutOfBoundsException: 2
Can you please help me out with this?
Thank you very much.