What is the maximum length of List in java? I mean that how many maximum elements can store in list?
This depends on the specific list implementation. Most people think it's Integer.MAX_VALUE
but it isn't limited to that. In fact the documentation of the size()
method merely states:
If this list contains more than
Integer.MAX_VALUE
elements, returnsInteger.MAX_VALUE
.
So it might as well contain more elements.