arraylist ensurecapacity 28int mincapacity 29 method in java

Solutions on MaxInterview for arraylist ensurecapacity 28int mincapacity 29 method in java by the best coders in the world

showing results for - "arraylist ensurecapacity 28int mincapacity 29 method in java"
Enoch
08 Apr 2019
1import java.util.ArrayList;
2public class ArrayListEnsureCapacityMethodExample
3{
4   public static void main(String[] args)
5   {
6      ArrayList<Integer> al = new ArrayList<Integer>(5);
7      al.add(25);
8      al.add(36);
9      al.add(50);
10      // increase the capacity of ArrayList to 10 elements
11      al.ensureCapacity(10);
12      // printing all the elements available in list
13      for(Integer num : al)
14      {
15         System.out.println("Numbers: " + num);
16      }
17   }
18}