ArrayList Test - AP Level A
Name ________________________________

{ private ArrayList<Integer> ar;

  1. Write a method that will return the smallest value in an ArrayList of Integers. Note the value being returned is an int.

    public int GetSmallest()

  2. Write a method that will delete the first occurence of a value from an ArrayList of Integers. The Arraylist is holding Integers. Return true or false from function.

    public boolean delete( int n)

  3. Write a method that will shift everyone 2 spots in the ArrayList.

    If ArrayList was 3 4 6 8 9 it would become 8 9 3 4 6

    public void shift2()

  4. Write a method that will change any odd numbers to the next even number. arrayList is holding Integers.

    public void changeOdd()

    2 7 4 6 9 would become 2 8 4 6 10

  5. Write a method that will return the average for an ArrayList of Integers.

    public double getAvg()