This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arraylist Size" Watch "Arraylist Size" New topic
Author

Arraylist Size

shruti patel
Ranch Hand

Joined: Mar 10, 2008
Posts: 52
How many number of objects we can store in an ArrayList. Is
there any limit?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

ArrayList uses arrays internally. These have a limit of Integer.MAX_VALUE. Therefore, that is also the limit of ArrayLists.

LinkedList on the other hand has no limit at all; if the size is larger than Integer.MAX_VALUE then size() will return Integer.MAX_VALUE.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

As long as your JVM is not out of memory , you can store any number of objects !


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Originally posted by Rob Prime:
ArrayList uses arrays internally. These have a limit of Integer.MAX_VALUE. Therefore, that is also the limit of ArrayLists.



Thanks Rob, I haven`t known that !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arraylist Size