How much data can a List can hold at the maximum?

Paul picture Paul · Sep 22, 2010 · Viewed 122.5k times · Source

How much data can be added in java.util.List in Java at the maximum?

Is there any default size of an ArrayList?

Answer

gustafc picture gustafc · Sep 22, 2010

It depends on the List implementation. Since you index arrays with ints, an ArrayList can't hold more than Integer.MAX_VALUE elements. A LinkedList isn't limited in the same way, though, and can contain any amount of elements.