title: How to debug my Java linked-list queue?
body: <p>I had basically no issue with linked lists in C++, but this is getting to me for some reason. I had a single node being printed out using the other classes in the package that were provided, but as I go on I just keep running into walls.</p>
  
  <p>The code below is in shambles due to me tinkering around. I just have no idea where to go from here. As of now that is getting a null pointer exception. </p>
  
  <p>Just for information: <code>poll()</code> is just removing the current head and returning it, <code>offer()</code> is adding to the rear. As of now the exception is at <code>oldLast.next = last</code> in the offer method.</p>
  
  <p>I am not asking for anyone to completely solve this. I just need some tips to progress.</p>
  
  <pre><code>public class FIFOQueue implements Queue {
  
  //put your name as the value of the signature.
  String signature = "name";
  
  Node head = new Node(null);
  Node pointer = head;
  Node first;
  Node last;
  Node prev;
  Node curr;
  
  class Node {
      Process process;
      Node next;
  
  
      Node(Process p) {
          this.process = p;
          this.next = null;
      }
  
  }
  
  @Override
  public void offer(Process p) {
  
  
      if(head == null)
      {
          head = new Node(p);
          first = head;
          last = head;
  
      }
  
      else
      {
  
          Node oldLast = last;
          Node newNode = new Node(p);
  
          last = newNode;
          oldLast.next = last;
  
  
      }
  
  
  
  }
  
  
  @Override
  public Process poll() {
  
  
      if(isEmpty())
          throw new NoSuchElementException();
  
      Node oldPointer = first;
  
      first = first.next;
      head = first;
  
  
          return oldPointer.process;
  }
  
  @Override
  public boolean isEmpty() {
  
  return head == null;
  
  }
  
  @Override
  public String getSignature() {
      return signature;
  }
  
  }
  </code></pre>