Close

Java 8 Streams - DoubleStream.min Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.DoubleStream

java.lang.AutoCloseableAutoCloseablejava.util.stream.BaseStreamBaseStreamjava.util.stream.DoubleStreamDoubleStreamLogicBig

Method:

OptionalDouble min()

Returns an OptionalDouble describing the minimum element of this stream, or an empty optional if this stream is empty. This is a special case of a reduction.

Examples


package com.logicbig.example.doublestream;

import java.util.stream.DoubleStream;

public class MinExample {

public static void main(String... args) {
DoubleStream ds = DoubleStream.of(1.0, 1.2, 2.0, 2.4, 3.0);
double v = ds.min()
.orElse(-1);
System.out.println(v);
}
}

Output

1.0




See Also