Close

Java 8 Streams - DoubleStream.sorted Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.DoubleStream

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

Method:

DoubleStream sorted()

This stateful intermediate operation returns a stream consisting of the elements of this stream in sorted order.

Examples


package com.logicbig.example.doublestream;

import java.util.stream.DoubleStream;

public class SortedExample {

public static void main(String... args) {
DoubleStream.of(3.0, 1.2, 2.0, 1.4, 3.0)
.sorted()
.forEach(System.out::println);
}
}

Output

1.2
1.4
2.0
3.0
3.0




See Also