An ArrayList can contain any number of elements up to Integer.MAX_VALUE - this is due to a constructive decision to use the int data type for indexes. However, the important thing is how you allocate memory for it - memory allocation is slow - and how you process / access the elements. However, from one aspect of storage you are limited to MAX_VALUE . In Java, this is 2 ^ 31-1 = 2,147,483,647.
For any normal use, this should be enough. However, if you need more, you can easily get the source code for it and modify it to use long as the index data type, and then be limited to Long.MAX_VALUE .
source share