Advertisement
LoganBlackisle

MainApp

Jul 31st, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. package linkedlist;
  2.  
  3. public class MainApp {
  4.  
  5.     public static void main(String[] args) {
  6.         SortedLinkedList list = new SortedLinkedList();
  7.  
  8.         String e1 = new String("albert");
  9.         String e2 = new String("david");
  10.         String e3 = new String("george");
  11.         String e4 = new String("jannick");
  12.         String e5 = new String("mogens");
  13.  
  14.         // ----------------SINGLE LIST--------------------------
  15.         list.addElement(e1);
  16.         list.addElement(e2);
  17.         list.addElement(e3);
  18.         list.addElement(e4);
  19.         list.addElement(e5);
  20.  
  21.         System.out.println("Should print elements after this:");
  22.         list.udskrivElements();
  23.  
  24.         System.out.println("number in the list via count method: " + list.countElements());
  25.         System.out.println();
  26.         System.out.println("number in the list via countRecursive method: " + list.countElementsRecursive());
  27.         System.out.println();
  28.  
  29.         list.removeLast();
  30.  
  31.         System.out.println("Should print elements after this:");
  32.         list.udskrivElements();
  33.  
  34.         System.out.println();
  35.         System.out.println(
  36.                 "an element has been removed via removeLast, should now give one less: " + list.countElements());
  37.         System.out.println();
  38.  
  39.         list.removeElement(e3);
  40.  
  41.         System.out.println("should print e1 (a): " + e1.toString());
  42.         System.out.println("should print e2 (m): " + e2.toString());
  43.         System.out.println("should print e3 (g): " + e3.toString());
  44.         System.out.println("should print e4 (d): " + e4.toString());
  45.         System.out.println("should print e5 (j): " + e5.toString());
  46.         System.out.println();
  47.         System.out.println(
  48.                 "an element has been removed via removeElement, should now give one less: " + list.countElements());
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement