Java - what is default capacity of ArrayList?

0 points
Asked by:
Dirask Community

What is the default capacity of the ArrayList in Java?

1 answer
0 points
Answered by:
Dirask Community

Default initial capacity of the ArrayList in Java is 10.

Go to the ArrayList class and search for DEFAULT_CAPACITY to see:

public class ArrayList<E> extends AbstractList<E>
        implements List<E>, RandomAccess, Cloneable,

     * Default initial capacity.
    private static final int DEFAULT_CAPACITY = 10;

   // ...
0 comments Add comment
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂