Skip to content

Instantly share code, notes, and snippets.

@rain0r
Created February 20, 2018 11:41
Show Gist options
  • Save rain0r/8b3fa4e26e6553242dfcfc204679578c to your computer and use it in GitHub Desktop.
Save rain0r/8b3fa4e26e6553242dfcfc204679578c to your computer and use it in GitHub Desktop.
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