实例:
interface InterTest {我们会发现在所有的实现类中,都默认实现了default修饰的方法。虽然在实现类中没有!
public void show();
<span style="color:#ff0000;">public default void pring() {
System.out.println("what are you doing now");
}</span>
}
class InterImplTest implements InterTest {
public void show() {
System.out.println("how are you");
}
}
class MainTest {
public static void main(String[] args) {
InterImplTest test = new InterImplTest();
<span style="color:#ff0000;">test.pring();</span>
test.show();
}
}