The homework question is here : https://i.stack.imgur.com/lFNYs.jpg
An ArrayIndexOutOfBoundsException
occurs when i try to transpose the array, and the question states that only one object can be used.
int arr
, int n
and and int m
are instance variables. The input for m,n
and arr[][]
has been taken earlier.
void transpose(Transarray A){
arr=new int[n][m];
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
arr[j][i] = A.arr[i][j];
}