Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.genuinevm.src;
- import java.util.stream.IntStream;
- public class Test {
- public static void main(String[] args) {
- IntStream stream = IntStream.range(0, 64);
- stream
- // Filter takes type IntPredicate
- // IntPredicate is a Functional Interface with a single function that takes type int and returns type boolean.
- // So we can use type inference to simply pass in Test::something which takes an int and returns boolean.
- .filter(Test::something)
- .forEach(System.out::println);
- }
- public static boolean something(int i) {
- return i < 10;
- }
- }
Advertisement