Check out example codes for "ArrayList ensureCapacity(int minCapacity) method in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.ArrayList;
public class ArrayListEnsureCapacityMethodExample
{
   public static void main(String[] args)
   {
      ArrayList<Integer> al = new ArrayList<Integer>(5);
      al.add(25);
      al.add(36);
      al.add(50);
      // increase the capacity of ArrayList to 10 elements
      al.ensureCapacity(10);
      // printing all the elements available in list
      for(Integer num : al)
      {
         System.out.println("Numbers: " + num);
      }
   }
}

Learn ReactJs, React Native from akashmittal.com