在 Java 8,接口能够有常量变量和形象办法。能够通过default关键字,在接口里写办法的代码,但没方法写公有办法。
在Java 9 ,反对在接口里写公有办法了。示例代码如下:

public interface MyInterface {    private void  test(){        System.out.println("private test method");    }    default void doTest(){        test();    }    public static void main(String[] args){        MyInterface myinterface = new MyInterface() {            @Override            public void doTest() {                MyInterface.super.doTest();            }        };        myinterface.doTest();    }}