LongStream concat(LongStream a, LongStream b) example

Description

LongStream concat(LongStream a, LongStream b) concatenates streams.

Syntax

concat has the following syntax.


static LongStream concat(LongStream a,   LongStream b)

Example

The following example shows how to use concat.


import java.util.stream.LongStream;
// w  ww.jav  a 2  s.  c  o  m
public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.concat(LongStream.rangeClosed(1L, 5L),LongStream.rangeClosed(1L, 6L));

    b.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