//TestArrayListRemove.java

import java.util.ArrayList;
import java.util.Scanner;

public class TestArrayListRemove
{
    private static Scanner keyboard = new Scanner(System.in);

    public static void main(String[] args)
    {
        ArrayList<Integer> a = new ArrayList<Integer>();
        for (int i=1; i<=5; i++) a.add(i*i);
        for (Integer entry: a) System.out.print(entry + " ");
        System.out.println();
        System.out.print("1Press Enter to continue ... ");
        keyboard.nextLine();

        a.remove(2);
        for (Integer entry: a) System.out.print(entry + " ");
        System.out.println();
        System.out.print("2Press Enter to continue ... ");
        keyboard.nextLine();

        a.remove(25);  //Causes a runtime error.
        //a.remove((Integer)25);  //Must remove 25 like this.
        for (Integer entry: a) System.out.print(entry + " ");
        System.out.println();
        System.out.print("3Press Enter to continue ... ");
        keyboard.nextLine();
    }
}

