Make your own free website on Tripod.com

import java.io.*;
import java.util.ArrayList;

public class Beatles
{

  public static void main(String[] args) throws IOException
  {
    ArrayList group = new ArrayList();
    group.add("John");
    group.add("Paul");
    group.add("Ringo");
    group.add("George");

   System.out.println(group);   // prints out
    System.out.println();

    // prints out arraylist 1 at a time
    for (int x=0; x < group.size();x++)
     System.out.println(group.get(x));

     System.out.println();

     int loc = group.indexOf("Mary");
     System.out.println(loc); // returns -1

     loc = group.indexOf("Paul");
     group.remove(loc);   // remove returns an object but can't
     System.out.println(group);  // receive it with String type?

     group.add("Fred");
     System.out.println(group); // John Ringo George Fred

     group.set(1,"Joe");
      System.out.println(group); // John Joe Georg Fred
  }
}