title: Is there such a thing as a "local interface" in Java?
body: <p>Java allows me to define local abstract classes, like in this example:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Foo {
  
      public void foo() {
          abstract class Bar {          // Bar is a local class in foo() ...
              abstract void bar();
          }
  
          new Bar() {                   // ... and can be anonymously instantiated
              void bar() {
                  System.out.println("Bar!");
              }
          }.bar();
      }
  }
  </code></pre>
  
  <p>For some reason, when I try to define a "local interface" instead of the local class, like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Foo {
  
      public void foo() {
          interface Bar {           // Bar was supposed to be a local interface...
              void bar();
          }
  
          new Bar() {               // ... to be anonymously instantiated
              void bar() {
                  System.out.println("Bar!");
              }
          }.bar();
      }
  }
  </code></pre>
  
  <p>Java complains that "The member interface Bar can only be defined inside a top-level class or interface". Is there a reason for this? Or am I missing a mistake I made?</p>