Example usage for java.util List stream

List of usage examples for java.util List stream

Introduction

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

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:Main.java

public static void main(String[] args) {

    List<Integer> l = getDatas();

    System.out.println(l.stream().map((a) -> (a.toString())).reduce((a, b) -> (a + b)).orElse("ko"));

}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("1", "2", "3", "4", "5");

    stringList.stream().mapToLong(n -> Long.parseLong(n)).filter(n -> n % 2 == 0).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("1", "1", "2", "3", "4");

    stringList.stream().limit(2).peek(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("5", "1", "2", "3", "4");

    stringList.stream().sorted().forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("1", "1", "2", "3", "4");

    stringList.stream().skip(2).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("1", "2", "3", "4", "5");

    stringList.stream().mapToInt(n -> Integer.parseInt(n)).filter(n -> n % 2 == 0).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<String> stringList = Arrays.asList("1", "1", "2", "3", "4");

    stringList.stream().distinct().forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
    boolean o = numbers.stream().noneMatch(n -> n % 2 == 0);

    System.out.println(o);//  w  w  w  . j  ava  2s .  co  m
}

From source file:Main.java

public static void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    numbers.stream().map(value -> value * 2).forEach(System.out::println);
}

From source file:Main.java

public static void main(String[] args) {
    List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    numbers.stream().filter(value -> value % 2 == 0).forEach(System.out::println);
}