其他分享
首页 > 其他分享> > Lambda表达式练习(抽象方法带无参返回值)

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);
}

 

标签:Flyable,void,System,带无参,println,返回值,out,public,Lambda
来源: https://www.cnblogs.com/lps1944900433/p/16096295.html