List of usage examples for java.util.stream Collectors minBy
public static <T> Collector<T, ?, Optional<T>> minBy(Comparator<? super T> comparator)
From source file:Main.java
public static void main(String[] args) { Stream<String> s = Stream.of("1", "2", "3"); Optional<String> o = s.collect(Collectors.minBy(Comparator.reverseOrder())); if (o.isPresent()) { System.out.println(o.get()); } else {/*from w ww . j ava 2 s . c o m*/ System.out.println("no value"); } }