IntStream peek(IntConsumer action) example

Description

IntStream peek(IntConsumer action) returns a stream consisting of the elements of this stream, performing the provided action.

Syntax

peek has the following syntax.


IntStream peek(IntConsumer action)

Example

The following example shows how to use peek.


import java.util.stream.IntStream;
//from  ww w  .  ja v  a 2s  .c o  m
public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.rangeClosed(1,7);
    i.peek(System.out::println); 
    
  }
}




















Home »
  Java Streams »
    Reference »




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