Reputation: 448
I have
List<int[]> allNumList = new ArrayList<>();
I am iterating over allNumList
and matching one condition in below code .
for (int[] arr : allNumList) {
for (int i : arr) {
if (i == numb) {
return false;
}
}
}
I want to do above code using Java 8.
Upvotes: 6
Views: 429
Reputation: 4496
boolean noMatch = allNumList.stream()
.flatMapToInt(Arrays::stream)
.noneMatch(i -> i == numb);
Upvotes: 19