this is a homework problem, but not really to be graded, just something to be used in future projects. I'm having problems with getting to display what I have in my list/nodes. Mainly I get an error when calling displayList.
Merge combines lists into new one which includes all list 1 and 2 items.
Union includes only one of each duplicate from list 1 and 2.
Intersection only includes duplicates from list 1 and 2, not from same list.
Note in merge method the code in note form is just an alternative form of current one I believe.
//Kevin Clement
//Homework 2
   class LinkedListHomework
   {
      public static ListNode Merge(ListNode List1, ListNode List2)
      {
         ListNode head, tail;
         head = tail = new ListNode( "Hi1");
         while(List1 != null && List2 != null)
         {
            if(List1.getItem().toString().compareTo(List2.getItem().toString()) < 0)
            {
               tail.setNext(new ListNode(List1.getItem()));
               List1 = List1.getNext();
            }
            else
            {
               tail.setNext(new ListNode(List2.getItem()));
               List2 = List2.getNext();
            }
            tail = tail.getNext();
         }
      // while(List1 != null)
      // {
      // tail.setNext(new ListNode(List1.getItem()));
      // tail = tail.getNext();
      // List1 = List1.getNext();
      // }
      // 
      // while(List2 != null)
      // {
      // tail.setNext(new ListNode(List2.getItem()));
      // tail = tail.getNext();
      // List2 = List2.getNext();
      // }
         return head.getNext();
      }
   // public static ListNode Union(ListNode List1, ListNode List2)
   // {
   // 
   // 
   // 
   // }
   // // public static ListNode Intersection(ListNode List1, ListNode YList2)
   // {
   // 
   // }
      public void displayList()
      {
         ListNode temp = head;
         System.out.print("head");
         while(temp != null)
         {
            System.out.print("--> " + temp.getItem());
            temp = temp.getNext();
         }
         System.out.print("\n\n");
      }
      public static void main(String args[])
      {
         ListNode A = new ListNode("Adam", new ListNode("Andrew", new ListNode("Kyle", new ListNode("Luc", new ListNode("Michael", new ListNode("Tony"))))));
         ListNode B = new ListNode("Adam", new ListNode("Fallon", new ListNode("Jim", new ListNode("Kyle", new ListNode("Nina", new ListNode("Shea", new ListNode("Tony")))))));
         displayList(A);
         A.displayList();
      }
   }
Okay here are my errors, I feel that copying them down will be more helpful to you guys than me trying to explain what's wrong.
LinkedListHomework.java:61: cannot find symbol  
symbol  : variable head 
location: class LinkedListHomework  
         ListNode temp = head;  
                         ^  
LinkedListHomework.java:78: displayList() in LinkedListHomework cannot be applied to (ListNode)
         displayList(A);  
         ^  
LinkedListHomework.java:79: cannot find symbol  
symbol  : method displayList()  
location: class ListNode  
            A.displayList();  
             ^  
3 errors
