1. Lambda表达式
    1. @FunctionalInterface
    2. interface MyOperation{
    3. abstract float operation(float a, float b);
    4. }
    5. @Test
    6. public void testLambda(){
    7. float a = 123;
    8. float b = 234;
    9. // 有参数、有返回值、多条语句使用{ }
    10. float ret1 = fun(a, b, (float x, float y) -> {
    11. System.out.println("求和计算");
    12. return x + y;
    13. });
    14. System.out.println(ret1);
    15. // 参数类型可省略,仅一条返回值语句,return可省略
    16. float ret2 = fun(a, b, ( x, y) -> x + y);
    17. System.out.println(ret2);
    18. }
    19. private float fun(float a, float b, MyOperation m){
    20. return m.operation(a, b);
    21. }