This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Size" Watch "ArrayList Size" New topic
Author

ArrayList Size

narayana arya
Greenhorn

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: http://aspose.com/file-tools
 
subject: ArrayList Size
 
It's not a secret anymore!