ArrayList.ensureCapacity(int minCapacity) has the following syntax.
public void ensureCapacity(int minCapacity)
In the following code shows how to use ArrayList.ensureCapacity(int minCapacity) method.
/*from w w w. j a v a 2s. co m*/ import java.util.ArrayList; public class Main { public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer> (5); arrlist.add(10); arrlist.add(50); arrlist.add(30); arrlist.ensureCapacity(5000); } }