title: Java nested inner class access outer class variables
body: <p>Is it possible for the nested inner classes ABar and BBar to access main class's variables? For example:</p>
  
  <pre><code>public class Foo {
      public ABar abar = new ABar();
      public BBar bbar = new BBar();
      public int someCounter = 0;
  
      public class ABar {
          public int i = 0;
          public void someMethod(){
              i++;
              someCounter++;
          }
      }
  
      public class BBar {
          public void anotherMethod(){
              bbar.someMethod();
              someCounter++;
          }
      }
  }
  // then called using: //
  Foo myFoo = new Foo();
  myFoo.bbar.anotherMethod();
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Seems the code I typed would have worked if i'd have tried it first; was trying to get help without being too specific. The code I'm actually having trouble with </p>
  
  <p>Fails because of the error 'cannot make static reference to the non-static field stage'</p>
  
  <pre><code>public class Engine {
      public Stage stage = new Stage();
          // ...
      public class Renderer implements GLSurfaceView.Renderer {
          // ...
          @Override
          public void onDrawFrame(GL10 gl) {
              stage.alpha++;
          }
      }
  
      public class Stage extends MovieClip {
          public float alpha = 0f;
      }
  </code></pre>