Java基础——Lambda学习
语法格式
(parameters) -> expression
或
(parameters) ->{ statements; }实质
public interface IFlower {
String getColor(String flowerName);
}IFlower flower = (String name) -> {if(name == "rose") return "red"; else return "unkonwn";};
System.out.println(flower.getColor("rose")); //打印:red参考资料
Last updated