The essence of the task is to create an ArrayList and add ordinary arrays to it, which must then be filled with data. There was such a question, how are arrays filled in an ArrayList? Specifically incomprehensible entry in the internal cycle:
for (int i = 0; i < nums.size(); i++) { for (int j = 0; j<nums.get(i).length; j++ ) { nums.get(i)[j] = i; } } Here is the whole code of the method:
public static ArrayList<int[]> createList() { ArrayList<int[]> nums = new ArrayList<int[]>(); nums.add(new int[5]); nums.add(new int[2]); nums.add(new int[4]); nums.add(new int[7]); nums.add(new int[0]); Random r = new Random(); for (int i = 0; i < nums.size(); i++) { for (int j = 0; j<nums.get(i).length; j++ ) { nums.get(i)[j] = i; } } return nums; }