Here you can find the source of transpose(Object[][] matrix)
Parameter | Description |
---|---|
matrix | Object[][] Matriz a ser transposta |
public static Object[][] transpose(Object[][] matrix)
//package com.java2s; //License from project: Open Source License public class Main { /**/*ww w. j a v a 2 s . co m*/ * Transpoe a matriz (Transforma linhas em colunas e vice versa) * * @param matrix {@code Object[][]} Matriz a ser transposta * @return {@code Object[][]} Matriz transposta */ public static Object[][] transpose(Object[][] matrix) { Object[][] transposed = new Object[matrix[0].length][matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { transposed[j][i] = matrix[i][j]; } } return transposed; } /** * Transpoe a matriz (Transforma linhas em colunas e vice versa) * * @param matrix {@code Integer[][]} Matriz a ser transposta * @return {@code Integer[][]} Matriz transposta */ private Integer[][] transpose(Integer[][] matrix) { Integer[][] transposed = new Integer[matrix[0].length][matrix.length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[i].length; j++) { transposed[j][i] = matrix[i][j]; } } return transposed; } }