File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes ArrayList Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Size" Watch "ArrayList Size" New topic

ArrayList Size

narayana arya

Joined: Dec 12, 2005
Posts: 12
Does anybody knows ArrayList Maximum Size?
if i give ArrayList al=new ArrayList(Integer.MAX_VALUE);

then it is giving this exception:

java.lang.OutOfMemoryError: Requested array size exceeds VM limit
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Integer.MAX_VALUE is the maximum size of an ArrayList.
You are encountering an exhaustion of heap space (a failed alloc by the VM).
You can simply give your VM more heap space using the -Xmx option when you start it up

Tony Morris
Java Q&A (FAQ, Trivia)
I agree. Here's the link:
subject: ArrayList Size
Similar Threads
regrading ArrayList
please tell me
size of the list
default size of arraylist
how arraylist increases it size automatically?