title: java - a nonstatic field inside a static class
body: <p>It's my first time coming across such pattern of code, it might be fairly familiar to advanced gurus out there:  </p>
  
  <pre><code>public static class Myclass{
      public static class myChildClass{
          public int a =1;   //this doesn't give an error although I expected it should be declared static
      }
  }  
  </code></pre>
  
  <p>I can't instantiate the static inner class and I can't access the variable <code>int a</code> outside the class, so does this variable become private to the class? Why does java allow this instead of complaining it be declared static?</p>