How to trim the size of ArrayList to current Size in Java ?


Declaration :

Explanation :

Purpose trimToSize() method trims the capacity of this ArrayList equal to list's current size
Parameters NA
Return Value NA
Exception NA

Example

The following example shows the usage of java.util.Arraylist.trimToSize() method.

Output :