Languages

Java - what is default capacity of ArrayList?

0 points
Asked by:
halfera
321

What is the default capacity of the ArrayList in Java?

1 answer
0 points
Answered by:
halfera
321

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, java.io.Serializable
{
    //...

    /**
     * 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.

❤️💻 🙂

Join