| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,20 +7,19 @@ | |||
| 7 | 7 | public class Reducing{ | |
| 8 | 8 | ||
| 9 | 9 | public static void main(String...args){ | |
| 10 | - | ||
| 10 | + | ||
| 11 | 11 | List<Integer> numbers = Arrays.asList(3,4,5,1,2); | |
| 12 | 12 | int sum = numbers.stream().reduce(0, (a, b) -> a + b); | |
| 13 | 13 | System.out.println(sum); | |
| 14 | - | ||
| 14 | + | ||
| 15 | 15 | int sum2 = numbers.stream().reduce(0, Integer::sum); | |
| 16 | 16 | System.out.println(sum2); | |
| 17 | - | ||
| 17 | + | ||
| 18 | 18 | int max = numbers.stream().reduce(0, (a, b) -> Integer.max(a, b)); | |
| 19 | 19 | System.out.println(max); | |
| 20 | - | ||
| 20 | + | ||
| 21 | 21 | Optional<Integer> min = numbers.stream().reduce(Integer::min); | |
| 22 | - min.ifPresent(v -> System.out.println(v)); | ||
| 23 | - | ||
| 22 | + min.ifPresent(System.out::println); | ||
| 24 | 23 | ||
| 25 | 24 | int calories = menu.stream() | |
| 26 | 25 | .map(Dish::getCalories) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments