[Solved] How to change values’s position in 2d array in java? [closed]


You can use this function for the same:

public static String[][] transpose(String[][] m){
    String[][] temp = new String[m[0].length][m.length];
    for (int i = 0; i < m.length; i++)
        for (int j = 0; j < m[0].length; j++)
            temp[j][i] = m[i][j];
    return temp;
}

Hope it helps.

1

solved How to change values’s position in 2d array in java? [closed]