title: Java Generics and Static Factory Methods -- Syntax
body: <p>Here's what I've got:</p>
  
  <pre><code>public class Node&lt;T&gt; {
  
      // instance variables
      private Node&lt;T&gt; next;
      private T data;
  
      // construct with data
      private Node(T data){
          next = null;
          this.data = data;
      }
  
      // construct without data
      private Node(){
          next = null;
          this.data = null;
      }
  
      // static factory method
      public static &lt;T&gt; Node&lt;T&gt; newNodeWithData(T data){
          return new Node&lt;T&gt;(data);
      }
  
      // static factory method
      public static &lt;T&gt; Node&lt;T&gt; newNode(){
          return new Node&lt;T&gt;();
      }
  ...
  }
  </code></pre>
  
  <p>My question really just about the syntax of generics coupled with that of a static factory method. I don't really understand <em>why</em> we put the &lt; T > before the return type in the method declaration. Is it kind of like typecasting? Any help would be much appreciated!</p>