Example usage for java.util.stream LongStream forEach

List of usage examples for java.util.stream LongStream forEach

Introduction

In this page you can find the example usage for java.util.stream LongStream forEach.

Prototype

void forEach(LongConsumer action);

Source Link

Document

Performs an action for each element of this stream.

Usage

From source file:Main.java

public static void main(String[] args) {
    LongStream.Builder b = LongStream.builder();
    b.accept(2L);/*from w w w .ja  v  a2  s.com*/
    b.accept(2L);
    b.accept(2L);

    LongStream s = b.build();
    s.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.of(1, 2, 3, 4);
    LongStream l = i.asLongStream();
    l.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.of(1L);

    b.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.range(1L, 5L);

    b.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.rangeClosed(1L, 5L);

    b.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, Long.MAX_VALUE, Long.MIN_VALUE);

    b.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.of(6, 5, 7, 1, 2, 3, 3);
    LongStream d = i.mapToLong(n -> {
        return (long) n;
    });/*from w  ww. jav  a2 s  .c  o  m*/
    d.forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    LongStream b = LongStream.of(1L, 2L, 3L, 4L);

    b.filter(l -> l % 2 == 0);//www.j av a  2s  . co m
    b.forEach(System.out::println);

}