The problem is that you mixed up your dimensions, and tried to copy the 6 element vector into a 3x2 matrix rather than a 2x3 matrix.
You can tell because when you copy the values out of the matrix, i
goes from 0
to A.length
. When you copy them back in, i
goes from 0
to A[0].length
(= vektori_per_sortim.length/A.length
).
You could switch the i
and j
conditions, but it would be way cleaner to simply use your first loops and reverse the copy inside them:
k=0;
for(int i=0; i!=A.length; i++)
{
for(int j=0; j!=A[0].length; j++)
{
A[i][j] = vektori_per_sortim[k];
k++;
}
}