What is the shortest way to fill the ArrayList? Something like:
ArrayList<Integer[]> list = new ArrayList<Integer[]>();
list.add({1,10,1,1});
list.add({2,11,1,1});
Or:
ArrayList<Integer[]> list = ({1,10,1,1},{2,11,1,1});
What is the shortest way to fill the ArrayList? Something like:
ArrayList<Integer[]> list = new ArrayList<Integer[]>();
list.add({1,10,1,1});
list.add({2,11,1,1});
Or:
ArrayList<Integer[]> list = ({1,10,1,1},{2,11,1,1});
How about this shortcut:
List<int[]> list = Arrays.asList( new int[][]{{1,10,1,1}, {2,11,1,1}} );
To fix your first attempt:
ArrayList<Integer[]> list = new ArrayList<Integer[]>();
list.add(new Integer[]{1,10,1,1});
list.add(new Integer[]{2,11,1,1});
List<Integer[]> list = new ArrayList<Integer[]>();
list.add(new Integer[] { 1, 10, 1, 1 });
list.add(new Integer[] { 2, 11, 1, 1 });
Or here is a one-liner:
List<Integer[]> list = Arrays.asList(new Integer[] { 1, 10, 1, 1 }, new Integer[] { 2, 11, 1, 1 });