title: How to return object of private inner class object java
body: <p>How can I return the object of a private inner class</p>
  
  <pre><code>public class MainClass{
     public InnerClass getObj(){
         return this.new InnerClass()
     }
     private class InnerClass{
         InnerClass(){
         }
     }
  }
  -------------
  MainClass mc = new MainClass();
  mc.getObj(); // assume I am not holding it anywhere.
  </code></pre>
  
  <p>The above code is giving a null pointer exception, when I checked with the <code>try-catch</code> blocks.
  Also, when tried in debug mode, its says '<code>ClassNotFoundException</code>'</p>
  
  <p>But I can see the class file generated as MainClass$InnerClass.class</p>