I want to create a two-dimensional array, each element of which is a list, as in the image.
I tried ArrayList<List<User>>[][] arrayList = new ArrayList[3][3];
Is this a correct solution? Because when I try to add element like below code I get null error.
List<User> list = new ArrayList<User>();
arrayList[0][0].add(list);
User user = new User(1,3,2,6);
arrayList[0][0].get(0).add(user);
System.out.println(arrayList[0][0].get(0).get(0).id);

arrayList[0][0].add(list);Your "arrayList" which is actually an array doesn't have methods. You just assign a reference.arrayList[0][0] = list;