简易的Lambda练习
第十周 将下列程序改写为Lambda表达式
interface Cry{
public void cry();
}
public class Test{
public static void main(String args[]){
Cry hello=new Cry(){
public void cry(){
System.out.println("大家好,祝工作顺利!");
}
};
hello.cry();
}
}
使用了接口打印一段语句,改写lambda时只要去掉括号及函数的名字使用 ()->语句
interface Cry{
public void cry();
}
public class Main10 {
public static void main(String[] args) {
Cry hello = () -> System.out.println("大家好,祝工作顺利!");
hello.cry();
}
}