package com.company.java.oop.cls; interface IB { default void doMethod1() { System.out.println("IB"); } default void doMethod2() { System.out.println("domethod2"); } } class B implements IB {} public class TestInterface { public static void main(String[] args) { IB a2 = new B(); } }
JDK8以后接口是可以定义实现方法,必须需要default修饰符修饰
猜你喜欢
转载自www.cnblogs.com/mengbin0546/p/12004708.html
今日推荐
周排行