ArrayList of ArrayList in Java Last Updated : 11 Dec, 2018 Comments Improve Suggest changes Like Article Like Report We have discussed that an array of ArrayList is not possible without warning. A better idea is to use ArrayList of ArrayList. Java // Java code to demonstrate the concept of // array of ArrayList import java.util.*; public class Arraylist { public static void main(String[] args) { int n = 3; // Here aList is an ArrayList of ArrayLists ArrayList<ArrayList<Integer> > aList = new ArrayList<ArrayList<Integer> >(n); // Create n lists one by one and append to the // master list (ArrayList of ArrayList) ArrayList<Integer> a1 = new ArrayList<Integer>(); a1.add(1); a1.add(2); aList.add(a1); ArrayList<Integer> a2 = new ArrayList<Integer>(); a2.add(5); aList.add(a2); ArrayList<Integer> a3 = new ArrayList<Integer>(); a3.add(10); a3.add(20); a3.add(30); aList.add(a3); for (int i = 0; i < aList.size(); i++) { for (int j = 0; j < aList.get(i).size(); j++) { System.out.print(aList.get(i).get(j) + " "); } System.out.println(); } } } Output: 1 2 5 10 20 30 Comment More infoAdvertise with us Next Article ArrayList of ArrayList in Java kartik Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Java ArrayList of Arrays ArrayList of arrays can be created just like any other objects using ArrayList constructor. In 2D arrays, it might happen that most of the part in the array is empty. For optimizing the space complexity, Arraylist of arrays can be used. ArrayList<String[ ] > geeks = new ArrayList<String[ ] 2 min read Array vs ArrayList in Java In Java, an Array is a fixed-sized, homogenous data structure that stores elements of the same type whereas, ArrayList is a dynamic-size, part of the Java Collections Framework and is used for storing objects with built-in methods for manipulation. The main difference between array and ArrayList is: 4 min read Array to ArrayList Conversion in Java In Java, arrays are fixed-sized, whereas ArrayLists are part of the Java collection Framework and are dynamic in nature. Converting an array to an ArrayList is a very common task and there are several ways to achieve it.Methods to Convert Array to an ArrayList1. Using add() Method to Manually add th 3 min read Conversion of Array To ArrayList in Java Following methods can be used for converting Array To ArrayList: Method 1: Using Arrays.asList() method Syntax: public static List asList(T... a) // Returns a fixed-size List as of size of given array. // Element Type of List is of same as type of array element type. // It returns an List containing 5 min read Custom ArrayList in Java Before proceeding further let us quickly revise the concept of the arrays and ArrayList quickly. So in java, we have seen arrays are linear data structures providing functionality to add elements in a continuous manner in memory address space whereas ArrayList is a class belonging to the Collection 8 min read ArrayList in Java Java ArrayList is a part of the collections framework and it is a class of java.util package. It provides us with dynamic-sized arrays in Java. The main advantage of ArrayList is that, unlike normal arrays, we don't need to mention the size when creating ArrayList. It automatically adjusts its capac 9 min read Iterating over ArrayLists in Java ArrayList is a part of collection framework and is present in java.util package. It provides us with dynamic arrays in Java. Though, it may be slower than standard arrays but can be helpful in programs where lots of manipulation in the array is needed. This class is found in java.util package. With 5 min read Arrays Class in Java The Arrays class in java.util package is a part of the Java Collection Framework. This class provides static methods to dynamically create and access Java arrays. It consists of only static methods and the methods of an Object class. The methods of this class can be used by the class name itself.The 15 min read Convert Vector to ArrayList in Java There are multiple ways to convert vector to ArrayList, using passing the Vector in ArrayList constructor and by using simple vector traversal and adding values to ArrayList. Approach 1: Create a Vector.Add some values in Vector.Create a new ArrayList.Traverse vector from the left side to the right 3 min read Vector vs ArrayList in Java ArrayList and Vectors both implement the List interface, and both use (dynamically resizable) arrays for their internal data structure, much like using an ordinary array. Syntax: ArrayList: ArrayList<T> al = new ArrayList<T>(); Vector: Vector<T> v = new Vector<T>(); ArrayList 4 min read Like