title: Java Null Pointer Exception in Queue
body: <p>I have been trying to write a queue that uses a Node file, and I can't seem to figure out where the null pointer exception is an issue. I looked online a bit but I'm too new to Java I think to understand what I'm looking for here. Can anyone find it or at least lead me in the right direction??</p>
  
  <p>First the Queue:</p>
  
  <pre><code>public class Queue extends CharNode {
  public CharNode head;
  public CharNode tail;
  
  public Queue(){
      this.head = null;
      this.tail = null;}
  
  public boolean isEmpty(){
      return (head==null);}
  
  public void enqueue(Character character){
      if (isEmpty()){
          head.character = character;
          head.nextNode = tail;}
      else {
          CharNode oldTail = tail;
          tail = new CharNode();
          oldTail.character = character;
          oldTail.nextNode = tail;
      }
      }
  
  public Character dequeue(){
      if (isEmpty()) throw new RuntimeException("Queue Empty");
      head.character = character;
      head = head.nextNode;
      return character;
  }       
  public static void main(String[] args){
      Queue queue = new Queue();
      queue.enqueue('a');
      queue.enqueue('b');
      System.out.print(queue.dequeue());
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My CharNode file looks like:</p>
  
  <pre><code>public class CharNode {
  public Character character;
  public CharNode nextNode;
  public void charNode(Character character){
      this.character = character;
      this.nextNode = null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And the exception I received looks like:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  at Queue.enqueue(Queue.java:14)
  at Queue.main(Queue.java:32)
  </code></pre>