Tuesday, 22 March 2016

ArrayList Demo 2

import java.util.*;
class ArrayListDemo
{  public static void main(String[] args)
   { ArrayList al=new ArrayList();
System.out.println("Initial size of al : "+ al.size());
al.add("C");
al.add("A");
al.add("E");
al.add("B");
al.add("D");
al.add("F");
al.add(1,"A2");
al.add(new Integer(5));
System.out.println("Size of al after additions:"+al.size());
System.out.println("Contents of al:"+al.toString());
al.remove("F");
al.remove(2);
System.out.println("Size of al after deletions:"+al.size());
System.out.println("Contents of al:"+al);
  }
}

No comments:

Post a Comment