Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Java ArrayList Constructors

ArrayList Constructors

1) ArrayList()
Creates an empty ArrayList.

Example
ArrayList arrayList = new ArrayList();

2) ArrayList(int capacity)
Creates an ArrayList with specified initial capacity.

Example
ArrayList arrayList = new ArrayList(10);

3) ArrayList(Collection c)
Creates an ArrayList containing elements of the collection specified.

Example
ArrayList arrayList = new ArrayList(myCollection);

Where myCollection is an object of the type Collection.

Creates ArrayList of elements containing in the myCollection, in order returned by the myCollection’s Iterator.


<< Java ArrayList
    Adding Elements to Java ArrayList >>
Your rating: None Average: 1.7 (3 votes)
Share this

Post new comment