# size of arraylist

priyanaka jaiswal

Ranch Hand

Posts: 79

posted 3 years ago

No. Its initial

Size is the number of elements that the ArrayList contains.

Capacity is the number of elements that the ArrayList reserves space for. Note that this is an implementation detail of ArrayList - you don't normally need to know this to be able to use an ArrayList. It's just how ArrayList is implemented so that works efficiently.

If you add an element to an ArrayList, its size will grow by 1. So if you have an empty ArrayList (with size 0) and you add an element, its size will be 1.

- 1

priyanaka jaiswal wrote:By default the size of arraylist is 10

No. Its initial

**capacity**is 10 by default, but its

**size**will be 0.

Size is the number of elements that the ArrayList contains.

Capacity is the number of elements that the ArrayList reserves space for. Note that this is an implementation detail of ArrayList - you don't normally need to know this to be able to use an ArrayList. It's just how ArrayList is implemented so that works efficiently.

If you add an element to an ArrayList, its size will grow by 1. So if you have an empty ArrayList (with size 0) and you add an element, its size will be 1.

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |