Last active
June 29, 2025 02:23
-
-
Save rokon12/7e3bbfaaf669b98959a10a060ff34556 to your computer and use it in GitHub Desktop.
Code snippet from The Coding Café - snippet-2.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Integer> runningMax = values.stream() | |
.gather(Gatherers.scan( | |
() -> Integer.MIN_VALUE, | |
Integer::max | |
)) | |
.toList(); | |
System.out.println("Running maximum: " + runningMax); | |
// Output: [-2147483648, 1, 5, 5, 8, 8, 9, 9, 9, 9] | |
// ↑ initial ↑ 5>1 ↑ 8>5 ↑ 9>8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment