LongStream min() in Java with examples
java.util.stream.LongStream in Java 8, deals with primitive longs. It helps to solve the problems like finding maximum value in array, finding minimum value in array, sum of all elements in array, and average of all values in array in a new way. LongStream min() returns an OptionalLong describing the minimum element of this stream, or an empty optional if this stream is empty.
OptionalLong() min() Where, OptionalLong is a container object which may or may not contain a long value.
Example 1 :
Example 2 :
Example 3 :
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.