Created
February 20, 2018 11:41
-
-
Save rain0r/8b3fa4e26e6553242dfcfc204679578c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.SecureRandom; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class BooleanFilter { | |
public static void main(String... args) { | |
IntegerFilter rp = new IntegerFilter(); | |
rp.doWork(); | |
} | |
public void doWork() { | |
List<Integer> randoms = buildList(); | |
randoms.stream().filter(this::isNumberEven).forEach( | |
p -> { | |
System.out.println(String.format("%d is even", p)); | |
}); | |
} | |
private boolean isNumberEven(Integer number) { | |
return number.intValue() % 2 == 0; | |
} | |
private List<Integer> buildList() { | |
SecureRandom rand = new SecureRandom(); | |
List<Integer> randoms = new ArrayList<>(); | |
for (int i = 0; i < 5; i++) { | |
randoms.add(rand.nextInt()); | |
} | |
return randoms; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment