DoubleStream distinct() example

Description

DoubleStream distinct() returns a stream consisting of the distinct elements of this stream.

Syntax

distinct has the following syntax.


DoubleStream distinct()

Example

The following example shows how to use distinct.


import java.util.stream.DoubleStream;
//  w w  w .j a v  a 2 s. c o m
public class Main {
  public static void main(String[] args) {
    DoubleStream d = DoubleStream.of(1.2,1.2,2.3,4.5);
    
    DoubleStream r = d.distinct();
     
    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