JAVA 接口中默认方法

package com.interfaces;

public interface InterfaceOne {
    void aa();
    void bb();
    default void cc(){

    }
}

默认方法不是抽象方法,所以不被强制重写,但可以被重写,重写时候要去掉default关键字

public可以省略 default不能省略

posted @ 2022-04-23 09:42  phpwyl  阅读(183)  评论(0编辑  收藏  举报