Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Java Beginners Arrayexamples Convert Array to ArrayList

Related Tutorials


Share on Google+Share on Google+

Convert Array to ArrayList

In this section, you will learn about converting Array into ArrayList.

Convert Array to ArrayList

In this section, you will learn about converting Array into ArrayList.

Array is a data structure having fixed size which stores same type of elements in sequential manner. While ArrayList ,extends AbstractList and implements the List interface , supports dynamic array which can grow in size .

Situation comes when you have data in Array and you want to convert it into ArrayList. This can be done using asList() method as follows :

import java.util.*;

public class ConvertArrayToArrayList {
	public static void main(String args[]) {
		String[] states= {"UP", "Bihar", "Kolkata", "Delhi"};
		List stateslist = new Arrays(Arrays.asList(states));
		System.out.println("ArrayList of states: " + stateslist);


ArrayList of states: [UP, Bihar, Kolkata, Delhi]


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 4, 2013

Related Tutorials

Discuss: Convert Array to ArrayList  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image