Does the capacity of ArrayList decrease when we remove elements?

It doesn’t decrease this automatically. From the doc.

    public void trimToSize() 

Trims the capacity of this ArrayList instance to be the list’s current size. An application can use this operation to minimize the storage of an ArrayList instance.

Leave a Comment