Do Java arrays have a maximum size?

前端 未结 9 2129
礼貌的吻别
礼貌的吻别 2020-11-21 11:51

Is there a limit to the number of elements a Java array can contain? If so, what is it?

9条回答
  •  暖寄归人
    2020-11-21 11:56

    Actually it's java limitation caping it at 2^30-4 being 1073741820. Not 2^31-1. Dunno why but i tested it manually on jdk. 2^30-3 still throwing vm except

    Edit: fixed -1 to -4, checked on windows jvm

提交回复
热议问题