title: Basic Linked List type Queue that extends a very basic Node<T> in Java + Requesting Laymans Terms
body: <p>First, yes, this is for an assignment in school, but I am not looking for someone to re-write or overhaul my code in any way. My question is:</p>
  
  <p>I am asked to write a class that creates a Queue that extends Node (the latter as shown below)</p>
  
  <pre><code>public class Node&lt;T&gt;{
    protected      T  data;
    protected Node&lt;T&gt; next; 
  }
  </code></pre>
  
  <p>I have written up (a most likely very crude) method to do this, and a basic test program that stores integer types into a queue (hopefully). I dont know all the professional lingo, I have read the 'generics' documentation but may have missed a key point, I have read up on how a linked list works (their examples have alot more in the Node Class, which is something I'm not allowed to edit in this assignment), as well as circular arrays and such. when I run my code, I get an error that I wasn't expecting, regarding types. I will post my relevent code, can someone please generally explain what I did to get this (rather... where in my code I should have not used ?)</p>
  
  <pre><code>public class Queue&lt;T&gt; extends Node&lt;T&gt; {
  
      public Node base;
      public Node end;
  
      public void enqueue(T item) {
  
          Node newItem = new Node();
          newItem.data = item;
          newItem.next = null;
  
          if (isEmpty()) { //Sets to item count of 1
              this.base = newItem; //Base becomes the new item
              this.base.next = this.end; //Base Points Next as End
              this.end.next = this.base; //End points to the one before it (base)
          } 
          else { //Sets to item count above 1.
              this.end.next.next = newItem; //The Last Item Now Points Next as the New Item (End is never counted as an item)
              this.end.next = newItem; //End now points to the next final item.
          }
  
      }
  
      public T dequeue() {
  
          if (isEmpty()) {
              return (null);
          }
  
          else {
              T item = this.base.data;
  
              if (this.base.next == this.end) {
                  this.base = null;
                  this.end = null;
              }
  
              else {
                  this.base = this.base.next;
              }
  
              return (item);
          }
  
      }
  
      public int size() {
  
          int count = 0;
  
          for (Node node = base; node != null; node = node.next) {
              count++;
          }
          return count;
  
      }
  
      public boolean isEmpty() {
  
          return (base == null);
  
      }
  
      public Queue() {
  
          this.base = null;
          this.end = null;
  
      }
   }
  </code></pre>
  
  <p>The TestQueue.java code is:</p>
  
  <pre><code>public class TestQueue {
  
      public static void main(String args[]) {
  
          QueueStuff&lt;Integer&gt; firstQueue = new QueueStuff&lt;&gt;();
  
          firstQueue.enqueue (66);
          firstQueue.enqueue (6);
          firstQueue.enqueue (666);
          firstQueue.enqueue (0);
          firstQueue.enqueue (6666);
  
          //firstQueue.printQueue();
      }
  
  }
  </code></pre>
  
  <p>And the Error is as such:</p>
  
  <pre><code>incompatible types. 
     T item = this.base.data;
                       ^
     required: T
     found:    Object
     where T is a Type variable: T extends Object declared in class Queue
  </code></pre>