TestLList.java
Select all
/* TestLList.java David Klick CIS 260 2/2/2005 Program designed to do minor testing of LList.java class */ public class TestLList { public static void main(String[] args) throws MyListException { LList lst = new LList(); lst.addFirst(27); // 27 lst.add(13); // 27, 13 lst.addFirst(98); // 98, 27, 13 lst.addLast(52); // 98, 27, 13, 52 lst.add(2,77); // 98, 27, 77, 13, 52 System.out.println("Just added 98, 27, 77, 13, 52"); System.out.println(lst); System.out.println("Element #0: " + lst.getFirst()); System.out.println("Element #" + (lst.size()-1) + ": " + lst.getLast()); System.out.println("Element #3: " + lst.get(3)); System.out.println("Searching for 13: " + lst.indexOf(13)); lst.removeFirst(); lst.removeLast(); System.out.println("Just removed first and last elements"); System.out.println(lst); lst.remove(1); System.out.println("Just removed element at index 1"); System.out.println(lst); } }