Public interface S {
}
Public interface B {
Public static final S S = new S () {
Public String toString () {
Return "I realized in the interface";
}
public void dostring (String s) {
SYSTEM.OUT.PRINTLN ("I implemented on the interface");
}
};
}
public class Test {
public static void Main (string[] args) {
String s = b.s.tostring ();
System.out.println (s); I implemented it in the interface
}
}
(First of all, although my JDK version is 1.6, 1.8 can write a specific implementation in the interface)
This is a concrete implementation of the interface but my eclipse cannot call to dostring (), so the S interface can only override the 9 major methods of object
Although it is meaningless to make a concrete implementation of the interface by means of anonymous internal classes,
But it does not mean that the interface is not specifically implemented, but that it is not allowed
This article is from the "The_monster" blog, make sure to keep this source http://zzqnobody.blog.51cto.com/7059797/1622388
Can the Java interface have a specific implementation