-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBiMain.java
More file actions
28 lines (23 loc) · 860 Bytes
/
Copy pathBiMain.java
File metadata and controls
28 lines (23 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package lambda.lambda4;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
public class BiMain {
public static void main(String[] args) {
BiFunction<Integer, Integer, Integer> add = (a, b) -> a+b;
System.out.println("add.apply(1,2) = " + add.apply(1, 2));
BiConsumer<String, Integer> repeat = (s, a) -> {
for (int i = 0; i < a; i++) {
System.out.print("*");
}
System.out.print(s);
for (int i = 0; i < a; i++) {
System.out.print("*");
}
System.out.println();
};
repeat.accept("hello", 10);
BiPredicate<Integer, Integer> isGreater = (a, b) -> a > b;
System.out.println("isGreater.test(10,2) = " + isGreater.test(10, 2));
}
}