import java.util.*;
public class TrimArraylist{
public static void main(String args[]){
ArrayList<String> colors = new ArrayList<String>(8);
colors.add("Violet");
colors.add("Indigo");
colors.add("Green");
colors.add("Yellow");
colors.add("Orange");
colors.add("Red");
System.out.println("Size of the array is :"+colors.size());
colors.trimToSize();
System.out.println("The trimmed array is"+colors);
colors.add("Blue");
System.out.println("The trimmed array is"+colors);
}
}