Java 8 Streams Java Java API
java.util.stream.IntStream
IntStream filter(IntPredicate predicate)
Returns a stream consisting of the elements of this stream that match the given predicate.
package com.logicbig.example.intstream;import java.util.stream.IntStream;public class FilterExample { public static void main(String... args) { IntStream intStream = IntStream.of(1, 2, 3, 2, 5, 4); intStream.filter(i -> i % 3 == 0) .forEach(System.out::println); }}
3