title: Declaring static generic variables in a generic class
body: <p>I've read that you cannot declare static variables/methods inside a generic class and I really have no idea how to solve my problem or work around it so I ask for your guidance.</p>
  
  <p>What I want is a generic "index" that all of my core classes will extend.
  I'm creating a game-engine and an example is that I will have different gamestates who all extends <code>State</code> who in turn extends <code>Nexus&lt;State&gt;</code>. The reason I want the static head and tail is so that I can keep a linked list of all gamestates since they're all added to that list upon creation.</p>
  
  <p>Another example is that I will have different gameobjects who all extends <code>GameObject</code> who in turn extends <code>Nexus&lt;GameObject&gt;</code>.</p>
  
  <p>This is the index called <code>Nexus</code>:</p>
  
  <pre><code>public abstract class Nexus&lt;T&gt; 
  {
  
      private static T head = null;
      private static T tail = null;
  
      private T next = null;
      private static int num = 0;
  
      protected Nexus() { this.Add( (T)this ); }
  
      public T Add( T obj )
      {
  
          ((Nexus)obj).next = null;
          if( num++ == 0 ) head = tail = obj;
          else             tail = ( tail.next = obj );
  
          return obj;
  
      }
  
  }
  </code></pre>
  
  <p>If anyone got another solution or a workaround I'm all ears!</p>