title: Java: Interface with new keyword how is that possible?
body: <p>I was reading some sourcecode from Java libraries, and I am confused here;</p>
  
  <p>This code is from Document.java in jaxb library, and <strong>ContentVisitor is an Interface</strong> in same package, how can we create an instance of Interface with a new keyword? isn't that illegal?</p>
  
  <pre><code>public final class Document {
  .
  .
   private final ContentVisitor visitor = new ContentVisitor() {
      public void onStartDocument() {
  
          throw new IllegalStateException();
      }
  
      public void onEndDocument() {
          out.endDocument();
      }
  
      public void onEndTag() {
          out.endTag();
          inscopeNamespace.popContext();
          activeNamespaces = null;
      }
  }
  </code></pre>