How ArrayList work?

Hey I have doubt in how arrayList works?? and doubt is the default size of arraylist is 10 or 2.?

@awanish285,
The default size of an arraylist is 10.

When you create an object of ArrayList in Java without specifying a capacity, it is created with a default capacity which is 10. Since ArrayList is growable, it automatically resizes when the size (number of elements in arraylist) grows beyond a threshold.

Also, when an ArrayList is first created it is called empty ArrayList and size() will return zero. If you add elements then size grows one by one.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.