title: Trouble adding element to the rear of the queue using linked list
body: <p>i am trying to execute this queue program by using linked list implementations but it is returning me a NullPointerException error on pop() method. The program is neither adding elements nor deleting elements from the queue. I don't know what I did wrong. Please help me !!!!!!!!! </p>
  
  <pre><code> public class Node {
  public int data;
  public Node next;
  public Node(int d){
   d = data;
     }
  public void printNode(){
   System.out.println(" { " + data + " } ");
       }
       }
   import java.util.*;
  public class queue {
  
  public Node front;
  public Node rear;
  public int size;
  
  public queue(){
      front = null;
      rear = null;
      size = 0;
  }
  public boolean isEmpty(){
      return front == null;
  }
  public void enqueue(int data){
      Node newNode = new Node(data);
      if (isEmpty())
          newNode = front ;
      else
      rear.next = newNode;
      newNode = rear;
  }
  
  public int pop (){
      int temp = front.data;
      if (front.next == null)
          rear =null;
      front = front.next;
      return temp;
  }
  
  public int peek(){
      return front.data;
  }
  
  public int size(){
      Node current = front;
      while (current != null){
          current = current.next;
      size ++;
      }
      return size;
  }
  
  public void printList(){
      Node current = front;
      while(current != null){
          current.printNode();
          current = current.next;
      }
      System.out.println(" ");        
     }
   }
  
      public class test {
  
  public static void main(String[] args) {
  
      queue list = new queue();
      System.out.println("add elements to the rear: " );
      list.enqueue(5);
      list.enqueue(6);
      list.printList();
  
      System.out.println("delete elements from the front: ");
      list.pop();
      list.printList();
  
      System.out.println("the size is : " + list.size());
  }
  </code></pre>
  
  <p>}</p>