title: Java - cannot be referenced from a static context
body: <p>Here's my simple class:</p>
  
  <pre><code>public class Project {
      private int size;
      private Obj tree;
      static Obj insert( Obj t, String s ) { // t is null
          t = new Obj();
          t.val = s;
          return t;
      }
      public Project()
      {
        Obj tree = new Obj();
        int size=0;
      }
      public class Obj
      {
        public String val;
        public Obj()
        {
          val=null;
        }
      }     
  }
  </code></pre>
  
  <p>However, when I try to create a new object in the insert() function, I get this error:</p>
  
  <pre><code>Error: non-static variable this cannot be referenced from a static context
  </code></pre>