0
点赞
收藏
分享

微信扫一扫

InterfaceDefaultOnly


package com.shrimpking.t4;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Shrimpking
 * @create 2024/9/18 11:56
 */
interface InterfaceA2{
    //仅有默认方法的接口

    default public void otherPrint(){
        System.out.println("print default methods only in interfaceA");
    }
}

class SubClass2 implements InterfaceA2{
    //无具体实现
}

public class InterfaceDefaultOnly
{
    public static void main(String[] args)
    {
        SubClass2 obj = new SubClass2();
        obj.otherPrint();
    }
}

举报
0 条评论