目录: 接口的定义 jdk7-9,接口属性的变化 jdk8,default.public static method的提出解决了什么问题,使用时需要注意什么 jdk9的补充(引入private method.private static method) 新老生常谈:接口和抽象类的对比 单继承还是多继承 一.接口的定义: 首先让我们看一下接口的最新定义:What is an Interface,里面提到: In the Java programming language, an interface…
JDK8之前,interface中可以定义常量和抽象方法,访问修饰符是public. public interface A { /** a1和a2写法是等价的 */ public static final int a1 = 0; int a2 = 0; /** methodA1和methodA2写法是等价的 */ public abstract void methodA1(); void methodA2(); } JDK8起,允许我们在interface中使用static和default修饰方…