When when an arraylist’s logical size reaches its capacity, does it link a new array on to the end or does it make a new array and copy all the values into the new array?
Share
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.
That second one — it creates a new array and copies the old one over. If you want to avoid the copying, then you can use
LinkedListinstead, which does just add new links to a chain; but of course then you don’t get the fast indexing that a single array of elements provides.