IntStream boxed() example

Description

IntStream boxed() returns a Stream boxed to an Integer. This is an intermediate operation.

Syntax

boxed has the following syntax.


Stream<Integer> boxed()

Example

The following example shows how to use boxed.


import java.util.stream.IntStream;
import java.util.stream.Stream;
/*from ww w.j a  v a2s.co m*/
public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.of(1,2,3,4,5,6,7);
    Stream<Integer> o =  i.boxed();
    
    o.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