title: How to instantiate non-static inner class?
body: <p>I have an inner class, which I want to instantiate from the static method of the parent class as follows:</p>
  
  <pre><code>public class MyClass {
      public class B {
          private int v;
          B(int x) {
              v = x;
          }
  
          public void pr() {
              System.out.println(this.v);
          }
      }
  
      public static void main(String args[]) {
        int x=10;
        int y=25;
        int z=x+y;
      B bb = new B(3);
        System.out.println("Sum of x+y = " + z);
      }
  }
  </code></pre>
  
  <p>It is throwing an error as follows:</p>
  
  <pre><code>error: non-static variable this cannot be referenced from a static context
      B bb = new B(3);
             ^
  1 error
  </code></pre>