LongStream boxed() example

Description

LongStream boxed() returns a Stream boxed to a Long. This is an intermediate operation.

Syntax

boxed has the following syntax.


Stream<Long> boxed()

Example

The following example shows how to use boxed.


import java.util.stream.LongStream;
import java.util.stream.Stream;
//from  w ww.  j av  a 2  s  .co m
public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, Long.MAX_VALUE, Long.MIN_VALUE);
    Stream<Long> l = b.boxed();
    l.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