java中接口定义静态方法 接口里面的方法可以是静态方法吗?
接口里面的方法可以是静态方法吗?在JDK1.8中,接口中可以有静态方法,接口中的静态方法必须有一个主体。静态方法不需要实现。公共接口testInter{void printme()static voi
接口里面的方法可以是静态方法吗?
在JDK1.8中,接口中可以有静态方法,接口中的静态方法必须有一个主体。静态方法不需要实现。公共接口testInter{void printme()static void printus(){系统输出打印(“print in static method in interface”)}}类testInterImpl实现testInter{public void printme(){系统输出打印(“me”)}}公共类TestMain{公共静态void main(String[]args){系统输出打印(“123”)testInterImpl t=新建testInterImpl()t.printme()testInter.print1.8没问题。