I want to create a 2D array that each cell is an ArrayList!

If you want to create a 2D array of ArrayList.Then you can do this :

ArrayList[][] table = new ArrayList[10][10];
table[0][0] = new ArrayList(); // add another ArrayList object to [0,0]
table[0][0].add(); // add object to that ArrayList
Answer from AllTooSir on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › multidimensional-collections-in-java
Multidimensional Collections in Java - GeeksforGeeks
July 11, 2025 - Therefore, if we want to use a Multidimensional architecture where we can create any number of objects dynamically in a row, then we should go for Multidimensional collections in java. ... void add( int index, ArrayList<Object> e): It is used to insert the elements at the specified position in a Collection.
🌐
Reddit
reddit.com › r/learnjava › how do i create a 2d arraylist in java?
r/learnjava on Reddit: How do I create a 2d ArrayList in java?
June 25, 2020 -

I want to implement breadth first search in java. However I am stuck at making a adjacency list of the graph. The method on GeeksforGeeks declares the list as LinkedList<Integer> adj[]; Well this is actually an array of List and not dynamic too. Like you'll have to change the array size when you want to add some extra node. So, I tried List<List<Integer>> adj = new ArrayList<List<Integer>>(); and then made the inner ArrayList in a for loop as adj.add(new ArrayList<Integer>);. I am trying from so long still getting this error 'List cannot be resolved to a type'. I searched on Stack overflow and there too they have the same declaration as mine so I don't really know what I am doing wrong. Please help me.

Edit: I am using Java 11

🌐
Baeldung
baeldung.com › home › java › java list › multi dimensional arraylist in java
Multi Dimensional ArrayList in Java | Baeldung
January 8, 2026 - In this article, we discussed how to create a multidimensional ArrayList in Java. We saw how we can represent a graph using a 2-D ArrayList.
🌐
Scaler
scaler.com › home › topics › how to create 2d arraylist in java?
How to Create 2D ArrayList in Java? - Scaler Topics
April 20, 2024 - The following Java method to generate a two-dimensional list will work for us because it is two-dimensional: make an ArrayList of arraylists. We can initialize the 2D ArrayList Java object to outerArrayList1 in order to place an innerArraylist function inside of outerArrayList1.
🌐
Coderanch
coderanch.com › t › 683236 › java › adding-objects-ArrayList
adding objects to a 2D ArrayList (Java in General forum at Coderanch)
August 10, 2017 - JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility ... I am not sure you have got the concept of the relationship between Lists and Arrays. Because of peculiarities in generics, you cannot create an array of Lists of Strings as you showed (there are some fiddles you can employ depending on how strong your conscience is, however ‍). So you have declared an array of arrays (as Rob told you, it isn't a 2D array), and that is its type.
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
It is part of the java.util package and implements the List interface. The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to add or remove elements to/from an array, you have to create a new one).
Find elsewhere
🌐
W3Schools
w3schools.com › java › java_arrays_multi.asp
Java Multi-Dimensional Arrays
How Tos Add Two Numbers Swap Two Variables Even or Odd Number Reverse a Number Positive or Negative Square Root Area of Rectangle Celsius to Fahrenheit Sum of Digits Check Armstrong Num Random Number Count Words Count Vowels in a String Remove Vowels Count Digits in a String Reverse a String Palindrome Check Check Anagram Convert String to Array Remove Whitespace Count Character Frequency Sum of Array Elements Find Array Average Sort an Array Find Smallest Element Find Largest Element Second Largest Array Min and Max Array Merge Two Arrays Remove Duplicates Find Duplicates Shuffle an Array Fac
🌐
Scribd
scribd.com › presentation › 508611506 › 2D-Array
Java 2D ArrayList Example | PDF | String (Computer Science)
Get the world's best ebooks, audiobooks, podcasts, magazines, documents, and more. Find anywhere else. Home to the world's documents, 300M+ and counting.
🌐
Rose-Hulman Institute of Technology
rose-hulman.edu › class › csse › csse221 › 201410 › Capsules › Summaries › 07ArraysAndArrayListsSec2.pdf pdf
1D and 2D Arrays and ArrayLists Sources
You type out ArrayList<object type here>() and you don’t need to ... Int[][] newArray2D = new int[5][6]; (Creates a 2D Array with 5 rows and 6 columns that holds integers)
🌐
Codecademy
codecademy.com › learn › learn-java › modules › java-two-dimensional-arrays › cheatsheet
Learn Java: Two-Dimensional Arrays Cheatsheet | Codecademy
2D arrays are declared by defining a data type followed by two sets of square brackets. ... In Java, when accessing the element from a 2D array using arr[first][second], the first index can be thought of as the desired row, and the second index ...
🌐
Processing Forum
forum.processing.org › topic › how-to-create-a-2d-arraylist
How to create a 2D ArrayList - Processing Forum
February 20, 2013 - /** * 2D ArrayList (v2.1) * by Quarks (2013/Feb) * tweaked by GoToLoop * * http://forum.processing.org/topic/how-to-create-a-2d-arraylist */ // Declare & create a 2D array list final ArrayList< ArrayList<String> > words2D = new ArrayList(); // Add an element (another ArrayList of strings) // to the 1st dimension (we have row 0 now!) words2D.add( new ArrayList() ); // Get current number of rows // and last index number we can use int numRows = words2D.size(); int row = numRows - 1; // Add a string in position [row 0][col 0] words2D.get(row).add("Quarks"); // Add a string in position [0][1] word
🌐
Scaler
scaler.com › home › topics › two dimensional array in java
Two Dimensional Array In Java with Examples - Scaler Topics
June 8, 2024 - This article provides an overview of two-dimensional arrays in Java, covering all the theoretical aspects related to 2D arrays in Java, along with their implementation.
🌐
LeetCode
leetcode.com › problems › intersection-of-two-arrays
Intersection of Two Arrays - LeetCode
Can you solve this real interview question? Intersection of Two Arrays - Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order.
🌐
VisuAlgo
visualgo.net › en › array
Array - VisuAlgo
Java ArrayList all implement this variable-size array. Note that Python list and Java ArrayList are not Linked Lists, but are actually variable-size arrays.
🌐
GeeksforGeeks
geeksforgeeks.org › java › arrays-in-java
Arrays in Java - GeeksforGeeks
Once an array is created, its size is fixed and cannot be changed. For collections that can grow or shrink dynamically, Java provides classes like ArrayList or Vector.
Published   May 8, 2026
🌐
LeetCode
leetcode.com › problems › design-linked-list
Design Linked List - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
🌐
W3Schools
w3schools.com › java › java_linkedlist.asp
Java LinkedList
How Tos Add Two Numbers Swap Two Variables Even or Odd Number Reverse a Number Positive or Negative Square Root Area of Rectangle Celsius to Fahrenheit Sum of Digits Check Armstrong Num Random Number Count Words Count Vowels in a String Remove Vowels Count Digits in a String Reverse a String Palindrome Check Check Anagram Convert String to Array Remove Whitespace Count Character Frequency Sum of Array Elements Find Array Average Sort an Array Find Smallest Element Find Largest Element Second Largest Array Min and Max Array Merge Two Arrays Remove Duplicates Find Duplicates Shuffle an Array Fac
🌐
W3Schools
w3schools.com › java › java_arrays_reallife.asp
Java Arrays - Real-Life Examples
How Tos Add Two Numbers Swap Two Variables Even or Odd Number Reverse a Number Positive or Negative Square Root Area of Rectangle Celsius to Fahrenheit Sum of Digits Check Armstrong Num Random Number Count Words Count Vowels in a String Remove Vowels Count Digits in a String Reverse a String Palindrome Check Check Anagram Convert String to Array Remove Whitespace Count Character Frequency Sum of Array Elements Find Array Average Sort an Array Find Smallest Element Find Largest Element Second Largest Array Min and Max Array Merge Two Arrays Remove Duplicates Find Duplicates Shuffle an Array Fac
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-in-java
ArrayList in Java - GeeksforGeeks
ArrayList in Java is a resizable array provided in the java.util package.
Published   May 12, 2026