1  import java.util.ArrayList;
  2  
  3  /**
  4     This program tests the ArrayList class.
  5  */
  6  public class ArrayListTester
  7  {
  8     public static void main(String[] args)
  9     {
 10        ArrayList<BankAccount> accounts = new ArrayList<BankAccount>();
 11        accounts.add(new BankAccount(1001));
 12        accounts.add(new BankAccount(1015));
 13        accounts.add(new BankAccount(1729));
 14        accounts.add(1, new BankAccount(1008));
 15        accounts.remove(0);
 16  
 17        System.out.println("Size: " + accounts.size());
 18        System.out.println("Expected: 3");
 19        BankAccount first = accounts.get(0);
 20        System.out.println("First account number: " 
 21              + first.getAccountNumber());
 22        System.out.println("Expected: 1008");                  
 23        BankAccount last = accounts.get(accounts.size() - 1);
 24        System.out.println("Last account number: " 
 25              + last.getAccountNumber());
 26        System.out.println("Expected: 1729");                  
 27     }
 28  }