Can anyone explain what is difference between size and capacity of arraylist.
As It is said that size of arraylist when initialize is 0, and its capacity is 2.
What is difference between size and capacity in ArrayLsit?
Hii Mohit,
Size basically represent the number of element in an arraylist and capacity represent the total number of element that you can store in arraylist.
When you initialize new arraylist by default it’s capacity is two and since arraylist doesn’t contain any elements so it’s size is zero.