How to Convert an ArrayList Containing Integers to Primitive Int Array? Last Updated : 09 Feb, 2024 Comments Improve Suggest changes Like Article Like Report In Java, ArrayList is the pre-defined class of the Java Collection Framework. It is part of the java.util package. ArrayList can be used to add or remove an element dynamically in the Java program. It can be snipped dynamically based on the elements added or removed into the ArrayList. In this article, we will discuss how to convert an ArrayList containing Integers to a primitive int array. Methods to Convert an ArrayList containing Integers to Primitive Int ArrayTwo methods are mostly used to implement the ArrayList integers convert into a primitive integer array. add(): It is a pre-defined method of the ArrayList that can be used to add the elements into the ArrayList.get(): it is also an in-built method and it can be used to retrieve the elements into the ArrayList.Program to Convert an ArrayList Containing Integers to Primitive Int Array in Java Java // Java Program to convert an ArrayList // Containing Integers to primitive int array import java.util.ArrayList; //ArrayList convert into the primitive int array public class GFGexample { //main method public static void main(String[] args) { // Create the ArrayList named as arrayList ArrayList<Integer> arrayList = new ArrayList<>(); arrayList.add(10); arrayList.add(50); arrayList.add(100); arrayList.add(150); // Convert ArrayList<Integer> to int[] int[] intArray = convertToIntArray(arrayList); // print the result System.out.print("Original ArrayList: " + arrayList); System.out.println("\nConverted int array: " + java.util.Arrays.toString(intArray)); } // method to convert ArrayList<Integer> to int[] private static int[] convertToIntArray(ArrayList<Integer> list) { int[] intArray = new int[list.size()]; for (int i = 0; i < list.size(); i++) { intArray[i] = list.get(i); } return intArray; } } OutputOriginal ArrayList: [10, 50, 100, 150] Converted int array: [10, 50, 100, 150] Explanation of the Program:The above program is the example of the ArrayList can be convert into primitive integer array that Integer is the wrapper class that values can be convert into the normal primitive integer values into the program. It can be implemented first we have to create one Integer ArrayList then add the integer values into the ArrayList after that we can convert the ArrayList into the primitive integer. Comment More infoAdvertise with us Next Article How to Convert an ArrayList Containing Integers to Primitive Int Array? K kadambalamatclo Follow Improve Article Tags : Java Java Programs Arrays Java-Arrays Java-ArrayList +1 More Practice Tags : ArraysJava Similar Reads How to Convert an ArrayList of Objects to a JSON Array in Java? In Java, an ArrayList is a resizable array implementation of the List interface. It implements the List interface and is the most commonly used implementation of List. In this article, we will learn how to convert an ArrayList of objects to a JSON array in Java. Steps to Convert an ArrayList of Obje 3 min read How to Convert an ArrayList into a JSON String in Java? In Java, an ArrayList is a resizable array implementation of the List interface. It implements the List interface and is the most commonly used implementation of List. In this article, we will learn how to convert an ArrayList into a JSON string in Java. Steps to convert an ArrayList into a JSON str 2 min read How to clone an ArrayList to another ArrayList in Java? The clone() method of the ArrayList class is used to clone an ArrayList to another ArrayList in Java as it returns a shallow copy of its caller ArrayList. Syntax: public Object clone(); Return Value: This function returns a copy of the instance of Object. Below program illustrate the Java.util.Arra 2 min read How to Convert TreeMap to an ArrayList in Java? TreeMap is a part of the Java Collection framework. Java TreeMap contains values based on the key. It implements the NavigableMap interface and extends AbstractMap class. It provides an efficient means of storing key-value pairs in sorted order. Java TreeMap contains only unique elements. It cannot 4 min read Java Program to Convert Integer List to Integer Array There are many ways to convert integer List to ArrayList where in this article we will be discussing out 2 approaches as below: Using concept od streams in Java8Using Apache Commons LangUsing Guava Library Method 1: Using concept od streams in Java8 So, first, we will get to know about how to conver 3 min read Like