lambda表达式示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  //return A(a,b,c -> {return B(d,c);});

public class Java8Tester {
public static void main(String args[]){
Java8Tester tester = new Java8Tester();

//然后{return B(d,c);}相当于定义之后处理{ return a * b; };
MathOperation multiplication = (int a, int b) -> { return a * b; };
System.out.println("10 x 5 = " + tester.operate(10, 5, multiplication));
}


// 首先return A(a,b,c就相当于先定义了参数类型
interface MathOperation {
int operation(int a, int b);
}
}


声明:
本文章用于学习交流,严禁用于非法操作,出现后果一切自行承担,阅读此文章表示你已同意本声明。

Disclaimer:
This article is for study and communication. It is strictly forbidden to use it for illegal operations. All consequences shall be borne by yourself. Reading this article means that you have agreed to this statement.