Close

Java 8 Streams - IntStream.filter Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.IntStream

java.lang.AutoCloseableAutoCloseablejava.util.stream.BaseStreamBaseStreamjava.util.stream.IntStreamIntStreamLogicBig

Method:

IntStream filter(IntPredicate predicate)

Returns a stream consisting of the elements of this stream that match the given predicate.

Examples


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);
}
}

Output

3




See Also