How much data can be added in java.util.List in Java at the maximum?
Is there any default size of an ArrayList?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the
Listimplementation. Since you index arrays withints, anArrayListcan’t hold more thanInteger.MAX_VALUEelements. ALinkedListisn’t limited in the same way, though, and can contain any amount of elements.Edit: I realize this sounds like an endorsement of
LinkedList. But please note that although they don’t have a theoretical capacity limit, linked lists are usually an inferior choice to array-based data structures because of higher memory use per element (which lowers the list’s actual capacity limit) and poor cache locality (because nodes are spread all over RAM). It’s definitely not the data structure you want if you have more items than can be crammed into an array.