Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ArrayList will grow and shrink implicitly

User_19BPUMar 27 2012 — edited Mar 27 2012
Hi,

I have an ArrayList which is going to hold 1000 elements, hence I have defined the List as :-

List list = new ArrayList(1000);

If the number of elements is less than 1000 , in such case whether the ArrayList will shrink implictly and similarly
if the number of elements grows from 1000 to 1500 whether the ArrayList will increase the size implicitly to 1500?
I know that ArrayList will increase the size of its internal array to 50 % when compared to Vector?
If the above wont happen then it will be a problem as unnecessary memory space will be available List?
Please clarify.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2012
Added on Mar 27 2012
8 comments
2,661 views