ArrayList<E> Exercises

Completing this sequence of exercises will expose you to the ArrayList<E> Collection and its implementation of some of the important List<E> methods including size, isEmpty, get, add, remove and compareTo.
  1. Create a project called ArrayListOps and add a driver by the same name and the class field: ArrayList<String> names.
  2. In the main method, instantiate names and, immediately after, display the size() of the list.
  3. Use ArrayList's add(E) method to populate the list with a few names and then display the size of the list.
  4. Display the first object in the list.
  5. Display the last object in the list.
  6. Display the object in the list from back to front.
  7. Remove the first name in the list, display to verify, insert the name at the beginning again and display to verify. (4 statements)
  8. Make the first name the last name (1 statement). Display to verify.
  9. Remove the alphabetically-first name, reinsert it at the beginning of the list and display the list to verify.
  10. Implement a sort method that accepts names as the explicit parameter and returns a new list in alphabetic order. Display to verify.