Initialize List<List<Integer>> in Java
Use
List<List<Integer>> list = new ArrayList<List<Integer>>();
or since Java 1.7
List<List<Integer>> list = new ArrayList<>();
You can define it as List<List<Integer>> list = new ArrayList<List<Integer>>();
.
Then while defining the inner List
you can take care of initialising it as ArrayList<Integer>
.
You can define it as List<List<Integer>> list = new LinkedList();