Use

List<List<Integer>> list = new ArrayList<List<Integer>>();

or since Java 1.7

List<List<Integer>> list = new ArrayList<>();
Answer from Reimeus on Stack Overflow
🌐
Reddit
reddit.com › r/learnprogramming › how do i make integer lists in java?
r/learnprogramming on Reddit: How do I make integer lists in Java?
February 4, 2019 -

It seems a lot easier from the very little time I spent on Python before making the jump to Java. I'm taking a college night class on Java, and lists are one thing that are confusing me. How do they work in Java?

Discussions

java - Create a List of primitive int? - Stack Overflow
Is there a way to create a list of primitive int or any primitives in java like following? ... Is my only option, creating an array of int and converting it into a list or creating a list of Integer objects? More on stackoverflow.com
🌐 stackoverflow.com
Java integer list - Stack Overflow
I am trying to make java go trough a list of numbers. It chooses the first one, gives this as output, waits/sleeps like 2000 milliseconds and then give the next one as output, waits 2000 millisecon... More on stackoverflow.com
🌐 stackoverflow.com
[java] working with an ArrayList of ArrayList <Integer>
Well, when you call list.get(0), you're being given another list. You can call the same methods on it. So you can do things like list.get(0).get(0). Or more realistically, to loop through all the lists of lists, you'd do something like: for(int i = 0; i < list.size(); ++i) { List innerList = list.get(i); for(int j = 0; j < innerList.size(); ++j) { System.out.print(innerList.get(j)); System.out.print(" "); } System.out.println(); } Exactly the same logic as arrays, really. Just a different interface. That above code just gets values, but you can set values in the same manner. Eg, to construct a matrix of 0 ... 9, 10 ... 19, ... , 90 ... 99, you could use: List> list = new ArrayList>(10); for(int i = 0; i < 10; ++i) { List innerList = new ArrayList(10); list.set(i, innerList); for(int j = 0; j < 10; ++j) { innerList.set(j, i * 10 + j); } } More on reddit.com
🌐 r/learnprogramming
7
1
September 11, 2016
How do I make integer lists in Java?
Java has arrays, like int[], but they are not dynamically resizable, and there are some other idiosyncracies as well. Instead prefer to use the generic List interface. Most often, you will want to specifically use the ArrayList implementation, as this gives you O(1) random access and is the Java equivalent to a Python list. Java generics have the caveat that you can't use them with primitive types like int, so instead you should use a wrapper class like Integer. tl;dr: List More on reddit.com
🌐 r/learnprogramming
4
0
February 4, 2019
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
Elements in an ArrayList are actually objects. In the examples above, we created elements (objects) of type "String". Remember that a String in Java is an object (not a primitive type). To use other types, such as int, you must specify an equivalent wrapper class: Integer.
🌐
Baeldung
baeldung.com › home › java › java numbers › list of primitive integer values in java
List of Primitive Integer Values in Java | Baeldung
April 4, 2025 - This means we can’t do something like List<int>. Instead, we can use List<Integer> and take advantage of autoboxing. Autoboxing helps us use the List<Integer> interface as if it contained primitive int values.
🌐
GeeksforGeeks
geeksforgeeks.org › java › initializing-a-list-in-java
Initializing a List in Java - GeeksforGeeks
A List in Java is an ordered collection that allows duplicate elements. It is part of the java.util package and is implemented by classes such as ArrayList, LinkedList, Vector, and Stack.
Published: August 26, 2026
Find elsewhere
🌐
Blogger
javahungry.blogspot.com › 2020 › 01 › list-of-lists-in-java.html
How to Create and Iterate list of lists in Java with Examples | Java Hungry
Given below is an example of Integer list of lists: import java.util.*; public class JavaHungry { public static void main(String[] args) { // Create listOfLists in Java List<List<Integer>> listOfLists = new ArrayList<>(); // Creating innerList List<Integer> innerList = new ArrayList<>(); // ...
🌐
Baeldung
baeldung.com › home › java › java list › convert a list of strings to a list of integers
Convert a List of Strings to a List of Integers | Baeldung
June 9, 2025 - List<Integer> EXPECTED_LIST = Arrays.asList(1, 2, 3, 4, 5, 6, 7); In this tutorial, we’ll address three different ways to do that: ... For simplicity, we’ll use unit test assertions to verify whether our conversions work as expected. Next, let’s dive in. Java Stream API provides many convenient interfaces and lets us easily handle Collections as streams.
🌐
CodeJava
codejava.net › java-core › collections › java-list-collection-tutorial-and-examples
Java List Collection Tutorial and Examples
February 10, 2025 - List<Integer> listNumbers = new ArrayList<>(1000); It’s also possible to construct a list that takes elements from an existing collection, for example:
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › List.html
List (Java Platform SE 8 )
July 21, 2026 - This interface is a member of the Java Collections Framework. ... Collection, Set, ArrayList, LinkedList, Vector, Arrays.asList(Object[]), Collections.nCopies(int, Object), Collections.EMPTY_LIST, AbstractList, AbstractSequentialList ... Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
🌐
Quora
quora.com › Why-cant-I-initialise-List-List-Integer-as-List-List-Integer-list-new-ArrayList-ArrayList-Integer
Why can't I initialise List<List<Integer>> as List<List<Integer>> list = new ArrayList<ArrayList<Integer>>();? - Quora
Answer (1 of 2): Generics in Action!! This feature is provided by Generics in Java and it is a valid scenario across all versions of Java after version 1.5. Generics were introduced to the Java language to provide tighter type checks at compile time and to support generic programming. Now let'...
🌐
Techie Delight
techiedelight.com › home › java › convert int array to list of integer in java
Convert int array to List of Integer in Java | Techie Delight
July 7, 2026 - Box each element of the stream to an Integer using IntStream.boxed(). Use Collectors.toList() to accumulate the input elements into a new list.
🌐
W3docs
w3docs.com › home › code snippets › java › how to convert int[] into list in java?
How to convert int[] into List&lt;Integer&gt; in Java? | W3docs
To convert an int[] array into a List&lt;Integer&gt; in Java, you can use the Arrays.stream() method to create a stream of the array, and then use the mapToObj() method to map each element of the stream to an Integer object.
🌐
Baeldung
baeldung.com › home › java › java list › working with a list of lists in java
Working With a List of Lists in Java | Baeldung
April 3, 2025 - As the example above shows, we transform each inner list into an integer using the mapToInt() method. The integer is the size of each inner list.
🌐
YouTube
youtube.com › shukri abo tteen
How To Create An ArrayList of Integers | ArrayList in Java Tutorial - YouTube
In this video we will look at how to create an arraylist of primitive data types such as integers and doubles.
Published: January 22, 2021
Views: 5K
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-in-java
ArrayList in Java - GeeksforGeeks
ArrayList<Integer> arr = new ArrayList<>(); Creates an ArrayList initialized with elements from the specified collection. ArrayList<String> arr = new ArrayList<>(collection); This constructor is used to build an array list with the initial capacity ...
Published: May 12, 2026
🌐
Dot Net Perls
dotnetperls.com › arraylist-integer-java
Java - ArrayList int, Integer Examples - Dot Net Perls
import java.util.ArrayList; public class Program { public static void main(String[] args) { ArrayList<Integer> list = new ArrayList<>(); list.add( 2); list.add( 3); list.add( 7); // Version 1: use for-each loop. for (int value : list) { System.out.println("FOR 1: " + value); } // Version 2: ...
🌐
TutorialsPoint
tutorialspoint.com › How-to-convert-List-Integer-to-int-in-Java
How to convert List to int[] in Java?
July 30, 2019 - import java.util.ArrayList; import java.util.List; public class Tester { public static void main(String[] args) { List<Integer> list = new ArrayList<>(); list.add(new Integer(1)); list.add(new Integer(2)); list.add(new Integer(3)); list.add(new ...