Here you can find the source of transpose(double[][] arr)
public static double[][] transpose(double[][] arr)
//package com.java2s; //License from project: Open Source License public class Main { public static double[][] transpose(double[][] arr) { double[][] newArr = new double[arr[0].length][arr.length]; for (int x = 0; x < arr.length; x++) for (int y = 0; y < arr[x].length; y++) newArr[y][x] = arr[x][y]; return newArr; }// w ww. ja v a2 s.c o m public static Double[][] transpose(Double[][] arr) { Double[][] newArr = new Double[arr[0].length][arr.length]; for (int x = 0; x < arr.length; x++) for (int y = 0; y < arr[x].length; y++) newArr[y][x] = arr[x][y]; return newArr; } public static int[][] transpose(int[][] arr) { int[][] newArr = new int[arr[0].length][arr.length]; for (int x = 0; x < arr.length; x++) for (int y = 0; y < arr[x].length; y++) newArr[y][x] = arr[x][y]; return newArr; } public static Integer[][] transpose(Integer[][] arr) { Integer[][] newArr = new Integer[arr[0].length][arr.length]; for (int x = 0; x < arr.length; x++) for (int y = 0; y < arr[x].length; y++) newArr[y][x] = arr[x][y]; return newArr; } public static String[][] transpose(String[][] arr) { String[][] newArr = new String[arr[0].length][arr.length]; for (int x = 0; x < arr.length; x++) for (int y = 0; y < arr[x].length; y++) newArr[y][x] = arr[x][y]; return newArr; } }