title: Queue Using Linked List
body: <p>I am implementing a linked queue in Java. However, there is/are error/s when I run my code.</p>
  
  <pre><code>public class LinkedQueue&lt;E&gt; implements Queue&lt;E&gt; {
     private int count;
     private Node&lt;E&gt; front, rear;
  
     public LinkedQueue() {
        count = 0;
        front = rear = null;
     }
  
     public void enqueue (E element) {
        Node&lt;E&gt; node = new Node&lt;E&gt; ();
  
        if (isEmpty())
           front = node;
        else
           rear.setNext (node);
  
        rear = node;
        count++;
     }
  
     public E dequeue() throws QueueEmptyException {
        if (isEmpty())
           throw new QueueEmptyException  ("queue");
  
        E result = front.getElement();
        front = front.getNext();
        count--;
  
        if (isEmpty())
           rear = null;
  
        return result;
  
     }
  
     public E first() throws QueueEmptyException {
        if (isEmpty())
           throw new QueueEmptyException ("queue"); 
  
        return front.getElement();
     }
  
  
     public boolean isEmpty() {
        return (front == rear);
     }
  
  
     public int size() {
        return count;
     }
  
  
      public E front() throws QueueEmptyException {       
          if (isEmpty())
              throw new QueueEmptyException("Queue underflow.");
          return (E) front.getNext();
      }
  }
  </code></pre>
  
  <p>I've been configuring forever what's wrong in my LinkedQueue. Please help me fix the code. I'm new in Java and maybe the mistakes are caused by sytax errors.</p>