import java.util.List; import java.util.ArrayList; /** * The NameRunnerArrayList class will create an ArrayList object of the List interface type. * We will then add, remove, set, get, size, and use the equals methods in the ArrayList class. * @author Aaron Braskin * @version March 19th, 2015 */ public class NameRunnerArrayList { public static void main(String[] args) { // Generics - indicated by the use of angle brackets < > List names=new ArrayList(); if (names.isEmpty()) { System.out.println("The list is currently empty!"); } Name myName=new Name(); myName.setFirst("Aaron"); myName.setLast("Braskin"); names.add(myName); // add method of the List interface myName=new Name("Ken","Brenan"); names.add(myName); // Anonymous Instantiation names.add(0,new Name("Aaron","Braskin")); // Use the set method of the List interface myName=new Name("David","Conor"); Name replacedName=names.set(1, myName); names.add(names.size(), replacedName); names.remove(1); names.remove(replacedName); names.add(replacedName); for (int i=0; i