I want to make a function which can take any type of array (int, String, boolean, etc) and return an array of the same type with the rows and columns switched.
public static String[][] swap_rows_columns_str_arr(String[][] arr) {
    String[][] new_arr = new String[arr[0].length][arr.length];
    for (int col = 0; col < arr[0].length; col++) {
        for (int row = 0; row < arr.length; row++) {
            new_arr[col][row] = arr[row][col];
        }
    }
    return new_arr;
}
I've managed to get it work for singular datatypes, but how would I get it to work for any datatype?
 
     
     
    
>` than with arrays.
– DontKnowMuchBut Getting Better Dec 26 '21 at 19:06