StreamToLoop: special handling of max().orElse(MIN_VALUE), etc.

This commit is contained in:
Tagir Valeev
2018-03-12 15:22:15 +07:00
parent ebbdbbe432
commit c1f2c5c380
4 changed files with 76 additions and 4 deletions

View File

@@ -36,6 +36,15 @@ public class Main {
return strings.stream().mapToInt(String::length).min().orElseGet(supplier);
}
public static int testMinMaxValue(List<String> strings) {
return strings.stream().mapToInt(String::length).min().orElse(Integer.MAX_VALUE);
}
public static long testMaxMinValue(List<String> strings) {
long max = strings.stream().mapToLong(String::length).max().orElse(Long.MIN_VALUE);
return max;
}
public static void main(String[] args) {
System.out.println(testMaxComparator(Arrays.asList()));
System.out.println(testMaxComparator(Arrays.asList("a", "bbb", "cc", "d", "eee")));