title: Null pointer exception in Java at LinkedList using generics
body: <pre><code>    public class   List_manager&lt;E&gt; {
          Entry&lt;E&gt; first;
          Entry&lt;E&gt; last;
          public void add(E element) {
              Entry&lt;E&gt; e=new Entry(element,last);
              if (first==null) first=last;
          }
          public E get() {
              Entry&lt;E&gt; temp=first;
              first=first.next;
              return temp.data;
          }
          public boolean isEmpty() { return first==null; }
  
  
          private static class Entry&lt;E&gt; {
              Entry&lt;E&gt; next;
              E data;
              public Entry(E element,Entry&lt;E&gt; to) {
                  data=element;
                  next=to;
                  to=this;
              }
          }
      }
  
  //now the main class
  </code></pre>
  
  <p>Trying to make a linkedlist    </p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          Point p1=new Point(0,0); // 
          Point p2=new Point(12,5);
          Point p3=new Point(43,12);
          List_manager&lt;Point&gt; l=new List_manager&lt;Point&gt;();
          l.add(p1);
          l.add(p2);
          l.add(p3);
          System.out.println(l.get()); // here is an error occurs
          System.out.println(l.get());
      }
  }
  
  // Point
  </code></pre>
  
  <p>Just a simple point</p>
  
  <pre><code>public class Point {
      double x; 
      double y;
      public Point(double x,double y) {
          this.x=x;
          this.y=y;
      }
      public String toString() {
          return "("+Double.toString(x) + " , " + Double.toString(y) + ")";
      }
  }
  </code></pre>