title: how would I return my data in my rear node? im trying to create a dequeue rear function
body: <p>So as you can see this is my deque. I dont think im correctly using my rear pointer. Cause right now its only returning the value of the front of the list. I just need help trying to figure out how to return the value of the rear. its removing it correctly but
  <a href="https://i.stack.imgur.com/QUko4.png" rel="nofollow noreferrer">its returning the wrong value</a>. Sorry i tried to keep it as compact as I possibly could. But i wanted to ensure it was runable</p>
  <pre><code>public class LinkedDeque &lt;T&gt; implements DequeInterface&lt;T&gt;
  {
      protected LLNode&lt;T&gt; front;     // reference to the front of this queue
      protected LLNode&lt;T&gt; rear;      // reference to the rear of this queue
      protected int numElements = 0; // number of elements in this queue
  
  
    @Override
      public T dequeueRear ()throws QueueUnderflowException
      {
  
  
          if (isEmpty())
              throw new QueueUnderflowException(&quot;Dequeue attempted on empty queue.&quot;);
  
          LLNode&lt;T&gt; lastNode = front;
          LLNode&lt;T&gt; previoustolast = null;
  
              while(lastNode.getLink()!= null)
              {
                  previoustolast = lastNode;
                  lastNode= lastNode.getLink();
  
              }
              previoustolast.setLink(null);
  
              return lastNode.getInfo();
  
  
      }
   @Override
      public boolean isEmpty()
      {
          return (front == null);
  
      }
   public String toString() {
          String result = &quot;&quot;;
          LLNode&lt;T&gt; temp = front;
          while(temp!=null) {
              result += temp.getInfo()+&quot; &quot;;
              temp = temp.getLink();
          }
          return result;
      }
  
  }
  public class LLNode&lt;T&gt;
  {
    protected LLNode&lt;T&gt; link;
    protected T info;
  
    public LLNode(T info)
    {
      this.info = info;
      link = null;
    }
  
    public void setInfo(T info){
      this.info = info;
    }
    public T getInfo(){
      return info;
    }
    public void setLink(LLNode&lt;T&gt; link) {
      this.link = link;
    }
    public LLNode&lt;T&gt; getLink(){
      return link;
    }
  }
  
  public class LinkedDequeTestDriver
  {
      public static void main(String[] args)
      {
  
          LinkedDeque&lt;Integer&gt; myLinkedDeque = new LinkedDeque();
  
          myLinkedDeque.enqueueRear(10);
          myLinkedDeque.enqueueRear(20);
          myLinkedDeque.enqueueRear(30);
          myLinkedDeque.enqueueRear(40);
          myLinkedDeque.enqueueRear(50);
          System.out.println(&quot;Queue&quot;);
          System.out.println(myLinkedDeque);
          myLinkedDeque.dequeueRear();
          System.out.println(myLinkedDeque);
          myLinkedDeque.dequeueRear();
          System.out.println(myLinkedDeque);
          System.out.println(myLinkedDeque.dequeueRear());
      }
  
  public interface DequeInterface&lt;T&gt;
  {
    void enqueueFront(T element) throws QueueOverflowException;
    // Throws QueueOverflowException if this queue is full;
    // otherwise, adds element to the front of this queue.
  
    void enqueueRear(T element) throws QueueOverflowException;
    // Throws QueueOverflowException if this queue is full;
    // otherwise, adds element to the rear of this queue.
  
    T dequeueFront() throws QueueUnderflowException;
    // Throws QueueUnderflowException if this queue is empty;
    // otherwise, removes front element from this queue and returns it.
  
    T dequeueRear() throws QueueUnderflowException;
    // Throws QueueUnderflowException if this queue is empty;
    // otherwise, removes rear element from this queue and returns it.
  
    boolean isFull();
    // Returns true if this queue is full; otherwise, returns false.
  
    boolean isEmpty();
    // Returns true if this queue is empty; otherwise, returns false.
    
    int size();
    // Returns the number of elements in this queue.
  
    String toString();
  }
  
  
  
  </code></pre>