Java ArrayList of Arrays Last Updated : 08 Oct, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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[ ] >(); Example: Input :int array1[] = {1, 2, 3}, int array2[] = {31, 22}, int array3[] = {51, 12, 23} Output: ArrayList of Arrays = {{1, 2, 3},{31, 22},{51, 12, 23}}Approach: Create ArrayList object of String[] type, say, list.Store arrays of string, say, names[], age[] and address[] into list object.Print ArrayList of Array.Below is the implementation of the above approach: Java // Java ArrayList of Arrays import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // create an ArrayList of String Array type ArrayList<String[]> list = new ArrayList<String[]>(); // create a string array called Names String names[] = { "Rohan", "Ritik", "Prerit" }; // create a string array called Age String age[] = { "23", "20" }; // create a string array called address String address[] = { "Lucknow", "Delhi", "Jaipur" }; // add the above arrays to ArrayList Object list.add(names); list.add(age); list.add(address); // print arrays from ArrayList for (String i[] : list) { System.out.println(Arrays.toString(i)); } } } Output[Rohan, Ritik, Prerit] [23, 20] [Lucknow, Delhi, Jaipur] Comment More infoAdvertise with us Next Article ArrayList of ArrayList in Java R rohanchopra96 Follow Improve Article Tags : Java Java-ArrayList Practice Tags : Java Similar Reads ArrayList of ArrayList in Java 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 1 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 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 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 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 Join two ArrayLists in Java Given two ArrayLists in Java, the task is to join these ArrayLists. Examples:Input: ArrayList1: [Geeks, For, ForGeeks] , ArrayList2: [GeeksForGeeks, A computer portal] Output: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal] Input: ArrayList1: [G, e, e, k, s] , ArrayList2: [F, o, r, G, e, e, 1 min read Like