- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert Integer array list to integer array in Java?
To convert integer array list to integer array is not a tedious task. First, create an integer array list and add some elements to it −
ArrayList < Integer > arrList = new ArrayList < Integer > (); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500);
Now, assign each value of the integer array list to integer array. We used size() to get the size of the integer array list and placed the same size to the newly created integer array −
final int[] arr = new int[arrList.size()]; int index = 0; for (final Integer value: arrList) { arr[index++] = value; }
Example
import java.util.ArrayList; public class Demo { public static void main(String[] args) { ArrayList<Integer>arrList = new ArrayList<Integer>(); arrList.add(100); arrList.add(200); arrList.add(300); arrList.add(400); arrList.add(500); arrList.add(600); arrList.add(700); arrList.add(800); arrList.add(900); arrList.add(1000); final int[] arr = new int[arrList.size()]; int index = 0; for (final Integer value : arrList) { arr[index++] = value; } System.out.println("Elements of int array..."); for (Integer i : arr) { System.out.println(i); } } }
Output
Elements of int array... 100 200 300 400 500 600 700 800 900 1000
- Related Articles
- How to convert Integer array list to float array in Java?
- How to convert an object array to an integer array in Java?
- Program to convert set of Integer to Array of Integer in Java
- How to convert integer set to int array using Java?
- Convert integer array to string array in JavaScript?
- C# Program to convert integer array to string array
- How to convert String to Integer and Integer to String in Java?
- Convert a String to Integer Array in C/C++
- Program to convert List of Integer to List of String in Java
- Program to convert List of String to List of Integer in Java
- How to convert array of decimal strings to array of integer strings without decimal in JavaScript
- How to convert Float array list to float array in Java?
- How to convert Long array list to long array in Java?
- Convert Double to Integer in Java
- convert list to array in java

Advertisements