多线程是跟着狂神学的:
b站学习视频
package Thread;
// 匿名内部类
public class Demo {
public static void main(String[] args) {
Person p = (String food) -> {
System.out.println("i eat " + food);
};
// 去掉参数声明
p = (food) -> {
System.out.println("i eat " + food);
};
// 只有一个入参的话,去掉括号
p = food -> {
System.out.println("i eat " + food);
};
// 去掉花括号
p = food -> System.out.println("i eat " + food);
Me me = (song, time) -> System.out.println(song + time);
p.eat("rice");
}
}
interface Person{
void eat(String food);
}
interface Me{
void sing(String song, int time);
}