title: Classes nested into an interface
body: <p><strong>Why is it possible to define inner (aka <em>non-static nested</em>) classes into an interface?</strong></p>
  
  <p>Does it make any sense? They cannot exists within an instance of the containing interface, because interfaces cannot be instantiated, so...</p>
  
  <p>The following does compile:</p>
  
  <pre><code>interface MyInterface
  {
      static class StaticNestedClass
      {
          static int a()
          {
              return 0;
          }
          int b()
          {
              return 1;
          }
      }
      class InnerClass
      {
          static int a()
          {
              return 0;
          }
          int b()
          {
              return 1;
          }
      }
  }
  </code></pre>
  
  <p>Is there any difference between the 2 above classes? Is <code>static</code> actually taken into account?
  Note that if you change <code>interface</code> with <code>class</code>, you obviously get a compile error on <code>InnerClass</code>' <code>static int a()</code>.</p>
  
  <p>Furthermore, have a look at the following:</p>
  
  <pre><code>interface MyInterface
  {
      int c=0;
      static class StaticNestedClass
      {
          static int a()
          {
              return c;
          }
          int b()
          {
              return c+1;
          }
      }
      class InnerClass
      {
          static int a()
          {
              return c;
          }
          int b()
          {
              return c+1;
          }
      }
  }
  </code></pre>
  
  <p>Unlike when the outer <em>containing entity</em> is a class, here of course there is no such thing as "an inner (non-static nested) class can access outer's fields while a static nested class can't", because, given that our outer thingie is an interface, our <code>c</code> integer is implicitly static... Are <code>interface</code>'s nested classes implicitly static too?</p>
  
  <p>So once again, are <code>StaticNestedClass</code> and <code>InnerClass</code> just the same?</p>