How to change rows to columns in ArrayList<Integer[]>? For instance:
ArrayList<Integer[]> arr = ArrayList<Integer[]>();
arr.add(new Integer[]{1,2,3});
arr.add(new Integer[]{4,5,6});
It should be:
[1]: 1 4
[2]: 2 5
[3]: 3 6
If it´s impossible with ArrayList, what are the other options to store 2D data and change rows to columns?
Anything wrong with
int[][]? That would be the standard approach:Output:
If you must use Collections, use as a start: