I read some source code from Java libraries, and here I am confused;
This code is from Document.java in the jaxb library, and ContentVisitor is an interface in the same package, how can we instantiate an interface with a new keyword? is not illegal?
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; } }
java interface
user893334 Feb 06 '12 at 9:10 2012-02-06 09:10
source share