Skip to content

Commit 1a38020

Browse files
committed
adding min example with method reference and Optional
1 parent e1ff9b6 commit 1a38020

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/lambdasinaction/chap4/Reducing.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ public static void main(String...args){
1717

1818
int max = numbers.stream().reduce(0, (a, b) -> Integer.max(a, b));
1919
System.out.println(max);
20+
21+
Optional<Integer> min = numbers.stream().reduce(Integer::min);
22+
min.ifPresent(v -> System.out.println(v));
2023
}
2124
}

0 commit comments

Comments
 (0)