How to Convert an ArrayList Containing Integers to Primitive Int Array? Last Updated : 09 Feb, 2024 Summarize Comments Improve Suggest changes Share 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 Java Tutorial Java is a high-level, object-oriented programming language used to build web apps, mobile applications, and enterprise software systems. It is known for its Write Once, Run Anywhere capability, which means code written in Java can run on any device that supports the Java Virtual Machine (JVM).Java s 10 min read Java OOP(Object Oriented Programming) Concepts Java Object-Oriented Programming (OOPs) is a fundamental concept in Java that every developer must understand. It allows developers to structure code using classes and objects, making it more modular, reusable, and scalable.The core idea of OOPs is to bind data and the functions that operate on it, 13 min read Java Interview Questions and Answers Java is one of the most popular programming languages in the world, known for its versatility, portability, and wide range of applications. Java is the most used language in top companies such as Uber, Airbnb, Google, Netflix, Instagram, Spotify, Amazon, and many more because of its features and per 15+ min read Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Arrays in Java Arrays in Java are one of the most fundamental data structures that allow us to store multiple values of the same type in a single variable. They are useful for storing and managing collections of data. Arrays in Java are objects, which makes them work differently from arrays in C/C++ in terms of me 15+ min read Collections in Java Any group of individual objects that are represented as a single unit is known as a Java Collection of Objects. In Java, a separate framework named the "Collection Framework" has been defined in JDK 1.2 which holds all the Java Collection Classes and Interface in it. In Java, the Collection interfac 15+ min read Inheritance in Java Java Inheritance is a fundamental concept in OOP(Object-Oriented Programming). It is the mechanism in Java by which one class is allowed to inherit the features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones. A class that inherits from an 13 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Java Exception Handling Exception handling in Java allows developers to manage runtime errors effectively by using mechanisms like try-catch block, finally block, throwing Exceptions, Custom Exception handling, etc. An Exception is an unwanted or unexpected event that occurs during the execution of a program, i.e., at runt 10 min read Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its 8 min read Like