my dog learned polymorphism*
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 Android Security Essentials Live Lessons this week in the Android 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: 19655
    
  18

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
 
Similar Threads
Arraylist Vs LinkedHashMap
readonly ArrayList
Collections.copy method for lists ? how it works
How do you avoid an ArrayList object from being modified, i.e. avoid adding and deleting its content
why some classes are called deprecated & some legacy?