Lambda表达式练习(抽象方法带无参返回值)

package com.czie.iot1913.Java8.Lambda.LambdaTest01.Practice02;

/**
* FileName: FlyableDemo
* Author: lps
* Date: 2022/4/3 16:09
* Sign:刘品水 Q:1944900433
*/
public class FlyableDemo {
public static void main(String[] args) {
//匿名内部类
useFlyable(new Flyable() {
@Override
public void fly(String s) {
System.out.println(s);
System.out.println("鸡汤来咯 喝啊 奶奶的 怎么不喝 啊~");
}
});
System.out.println("=========================");

useFlyable((s -> {
System.out.println(s);
System.out.println("喝啊 奶奶的 怎么不喝 啊~嘎");
}));
}
private static void useFlyable(Flyable f){
f.fly("哈哈嗨 啊~");
}

}

package com.czie.iot1913.Java8.Lambda.LambdaTest01.Practice02;

/**
* FileName: Flyable
* Author: lps
* Date: 2022/4/3 16:09
* Sign:刘品水 Q:1944900433
*/
public interface Flyable {
void fly(String s);
}

 

posted @ 2022-04-03 16:24  刘品水  阅读(33)  评论(0编辑  收藏  举报