DoubleStream sorted() example

Description

DoubleStream sorted() returns a stream consisting of the elements of this stream in sorted order.

Syntax

sorted has the following syntax.


DoubleStream sorted()

Example

The following example shows how to use sorted.


import java.util.stream.DoubleStream;
//from w  w  w .  j  a va  2 s. c  om
public class Main {
  public static void main(String[] args) {
    DoubleStream d = DoubleStream.of(1.2,4.5,1.2,2.3);
    
    DoubleStream r = d.sorted();
     
    r.forEach(System.out::println);
  }
}

The code above generates the following result.





















Home »
  Java Streams »
    Reference »




Collectors
DoubleStream
DoubleStream.Builder
IntStream
IntStream.Builder
LongStream
LongStream.Builder
Stream
Stream.Builder