EatDemo

作者: 哈迪斯Java | 来源:发表于2021-12-11 08:43 被阅读0次

    interface Eatable {
    void eat();
    }

    public class EatDemo {

    public static void main(String[] args) {
        Eatable dog = ()->{
            System.out.println("小狗爱吃骨头");
        };
        
        Eatable cat = ()->{
            System.out.println("小猫爱吃鱼");
        };
        
        Eatable chick = ()->{
            System.out.println("小鸡爱吃毛毛虫");
        };
        
        dog.eat();
        cat.eat();
        chick.eat();
    }
    

    }

    相关文章

      网友评论

          本文标题:EatDemo

          本文链接:https://www.haomeiwen.com/subject/cvkbxrtx.html