When we open the source code of ArrayList, we can see that the author has parsed it:
/**
*The maximum size of the array to be allocated.
* Some vms keep some headers in the array.
*Trying to allocate a larger array may result in an
*OutOfMemory error: the requested array size exceeds the virtual machine limit
*/
Why is the maximum capacity of ArrayList in Java Integer.MAX_VALUE-8?
Guess you like
Origin blog.csdn.net/weixin_41699562/article/details/103921064
Ranking