How many pieces of data can list store in Java?

from the perspective of language, java.util.List is an interface, under which there are multiple N implementations, the most commonly used are ArrayList and LinkedList and its various inheritance or synchronization implementation (such as Vector/Queue/Stack)
ArrayList inside is to take the array storage, then the upper limit is Integer.MAX_VALUE
LinkedList inside is a LinkedList, theoretically infinite

also, everything in the List is in memory (although you can implement one yourself), so how much you can put depends on the size and type of stuff you’re putting. The
size aspect is easy to calculate, if one object is 1K, then 400,000 will take up at least 400M memory (not counting other usage).
virtual machine memory classification, if it is a common object, generally use the Heap space, if it is a constant or something like string.intern (), then use the Permanent Generation.

in actual development, the default memory size of virtual machine varies according to different virtual machine implementations. The maximum heap size can be adjusted with -xmx when the application is launched, such as adjusting the maximum heap size to 2G:

java -Xmx2048m cn.gefostudio.App

adjust the maximum size of the immortal band to 1G:

java -XX:MaxPermSize=1024m cn.gefostudio.App

Read More: