- min operation on stream returns an optional of the minimum item in the stream.
- Another implementation of min operation returns an optional of the minimum item in the stream with respect to a comparator function.
int stream one to three
IntStream oneToThree = IntStream.of(1, 2, 3);
int stream one to two
IntStream oneToTwo = IntStream.of(1, 2);
order by least number comparator
Comparator<Integer> orderByLeastNumber = (n1, n2) -> n1.compareTo(n2);
log.info("obtaining the min item in oneToThree stream: " + oneToThree.min());
log.info("obtaining min item in oneToTwo stream using a comparator: " + oneToTwo.boxed().min(orderByLeastNumber));