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.
- Create a project called ArrayListOps and add a driver by the same name and the class field: ArrayList<String> names.
- In the main method, instantiate names and, immediately after, display the size() of the list.
- Use ArrayList's add(E) method to populate the list with a few names and then display the size of the list.
- Display the first object in the list.
- Display the last object in the list.
- Display the object in the list from back to front.
- Remove the first name in the list, display to verify, insert the name at the beginning again and display to verify. (4 statements)
- Make the first name the last name (1 statement). Display to verify.
- Remove the alphabetically-first name, reinsert it at the beginning of the list and display the list to verify.
- Implement a sort method that accepts names as the explicit parameter and returns a new list in alphabetic order. Display to verify.