As we know ArrayList increases its size by 50% when elements are added(100% incase of Vector).Where can we find the implementation for this behavior?
Thx
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.
In
ArrayList:and
Vector:Note:
capacityIncrementdefaults to0unless set otherwise so the default behaviour of aVectoris to double every time the backing array needs to be expanded but if you setcapacityIncrementthen it will be incremented by that instead.Also in all cases (for
ArrayListandVector) the increase–regardless of what it is–is superseded if the new capacity still isn’t large enough, in which case the required capacity is used.