Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package linkedlist;
- public class MainApp {
- public static void main(String[] args) {
- SortedLinkedList list = new SortedLinkedList();
- String e1 = new String("albert");
- String e2 = new String("david");
- String e3 = new String("george");
- String e4 = new String("jannick");
- String e5 = new String("mogens");
- // ----------------SINGLE LIST--------------------------
- list.addElement(e1);
- list.addElement(e2);
- list.addElement(e3);
- list.addElement(e4);
- list.addElement(e5);
- System.out.println("Should print elements after this:");
- list.udskrivElements();
- System.out.println("number in the list via count method: " + list.countElements());
- System.out.println();
- System.out.println("number in the list via countRecursive method: " + list.countElementsRecursive());
- System.out.println();
- list.removeLast();
- System.out.println("Should print elements after this:");
- list.udskrivElements();
- System.out.println();
- System.out.println(
- "an element has been removed via removeLast, should now give one less: " + list.countElements());
- System.out.println();
- list.removeElement(e3);
- System.out.println("should print e1 (a): " + e1.toString());
- System.out.println("should print e2 (m): " + e2.toString());
- System.out.println("should print e3 (g): " + e3.toString());
- System.out.println("should print e4 (d): " + e4.toString());
- System.out.println("should print e5 (j): " + e5.toString());
- System.out.println();
- System.out.println(
- "an element has been removed via removeElement, should now give one less: " + list.countElements());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement