title: Instantiating an inner class within a main method
body: <p>When we try to instantiate an Inner class (aka: non-static Nested class) in java, say we do that in two cases:</p>
  
  <p>1.in a main method in the same file of the outer Class in which we have two options: (ex:)</p>
  
  <pre><code>public class Test1
  {
     class InnerClass
     {
  
     }
    public static void main(String[] args)
    {
       InnerClass inner = new Test1().new InnerClass();
    }
  }
  </code></pre>
  
  <p>or :</p>
  
  <pre><code>public class Test1
  {
     class InnerClass
     {
  
     }
    public static void main(String[] args)
    {
       Test1.InnerClass inner = new Test1().new InnerClass();
    }
  }
  </code></pre>
  
  <ol start="2">
  <li>In a another class (say different file), then we have the second option only and using the first option requires us (of course) to import the InnerClass..,</li>
  </ol>
  
  <p>Q: could you please explain why do we have the first option (without any import required) in the first case (the main method in the same file)?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I guess the answer to the first question is some how related to the core idea of inner classes. but then +Q:</p>
  
  <p>Q: Isn't an inner class a regular-member of an outer class, so if the inner class is not declared static (static nested class) then I suppose it is a non-static member and consequently its reference type, so why are we able to declare it within a static context (static method) ? </p>