List of usage examples for java.util List stream
default Stream<E> stream()
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().anyMatch(n -> n % 2 == 0); System.out.println(o);// ww w . j av a 2 s .c o m }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1", "1", "2", "3", "4"); stringList.stream().sorted(Comparator.reverseOrder()).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { List<Integer> list = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); list.stream().filter(x -> x % 3 == 0).sorted((x, y) -> y - x).map(x -> x * 3).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().allMatch(n -> n % 2 == 0); System.out.println(o);/*from w w w.j av a2s . co m*/ }
From source file:Main.java
public static void main(String... args) { List<Integer> numbers = Arrays.asList(3, 4, 5, 1, 2); int max = numbers.stream().reduce(0, (a, b) -> Integer.max(a, b)); System.out.println(max);/*from w w w. ja v a 2s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { List<Integer> numbers = Arrays.asList(3, 7, 9, 3, 1, 2, 1, 2, 3, 4, 5); numbers.stream().filter(n -> n % 2 == 1).sorted().forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { List<Point> points = Arrays.asList(new Point(12, 2)); points.stream().map(p -> p.getX()).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().map(value -> value * 2).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1.2", "2.2", "3", "4", "5"); stringList.stream().flatMap(n -> Stream.of(n)).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("1.2", "2.2", "3", "4", "5"); stringList.stream().flatMapToInt(n -> IntStream.of(Integer.parseInt(n))).forEach(System.out::println); }