Here you can find the source of transpose(List> table)
public static <T> List<List<T>> transpose(List<List<T>> table)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> List<List<T>> transpose(List<List<T>> table) { List<List<T>> ret = new ArrayList<List<T>>(); final int N = table.get(0).size(); for (int i = 0; i < N; i++) { List<T> col = new ArrayList<T>(); for (List<T> row : table) { col.add(row.get(i));//from w w w. j a v a2s .c o m } ret.add(col); } return ret; } }