title: Instantiating inner class of class
body: <p>Basically I have a java class Foo with a generic T and a inner class Foo2 which is using this generic T somehow like the following example:</p>
  
  <pre><code>public class Foo&lt;T&gt;
  {
    public class Foo2
    {
      private T t;
      public void setObject(T t)
      {
         this.t = t;
      }
    }
  }
  </code></pre>
  
  <p>After try and error (until the compiler don't throw a warning or error) how to create an instance of this inner class Foo2 I came up with the following:</p>
  
  <pre><code>Foo&lt;String&gt; foo = new Foo&lt;String&gt;();
  Foo2 foo2 = foo.new Foo2();
  </code></pre>
  
  <p>The second line <code>foo.new Foo2();</code> is something which is new for me and I don't know what exactly I'm doing here. For me it is somehow clear, that an instance of the class Foo2 has to know what class T is but the syntax <code>foo.new</code> is new for me. What am I doing here?</p>