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

Default size of ArrayList?

Hi,

I would like to know what is the default size of ArrayList? Also, what is the default initial capacity of an ArrayList.

Is there any method to increase the capacity of the ArrayList?

Thanks in advance.
No votes yet
Share this
1 answer
Rahimv's picture
As I understood from your question, you want to know what would be the size of ArrayList object you just created. Well, it would be 0. As you keep adding elements to ArrayList, it increases.

Regarding default initial capacity of ArrayList,  it would be 10. You can use ArrayList constructor to have it increased or decreased accroding to your use.

You can also use ensureCapacity method of Java ArrayList class.

Hope this helps...
Your rating: None Average: 3.5 (6 votes)