max. length of List in Java

前端 未结 3 1061
半阙折子戏
半阙折子戏 2021-01-11 17:10

What is the maximum length of List in java? I mean that how many maximum elements can store in list?

3条回答
  •  囚心锁ツ
    2021-01-11 18:07

    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, returns Integer.MAX_VALUE.

    So it might as well contain more elements.

提交回复
热议问题