ArrayListDemo.java.html

  1  /**
  2     This program demonstrates the array list implementation.
  3  */
  4  public class ArrayListDemo
  5  {
  6     public static void main(String[] args)
  7     {
  8        ArrayList staff = new ArrayList();
  9        staff.addLast("Diana");
 10        staff.addLast("Harry");
 11        for (int i = 1; i <= 10; i++)
 12        {
 13           staff.addLast("Tom" + i);      
 14        }
 15        staff.add(0, "Juliet");
 16        staff.remove(1);
 17        for (int i = 0; i < staff.size(); i++)
 18        {
 19           System.out.println(staff.get(i));
 20        }
 21     }
 22  }