Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Arraylist Size

 
shruti patel
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How many number of objects we can store in an ArrayList. Is
there any limit?
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as your JVM is not out of memory , you can store any number of objects !
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!