I am learning and new to the Java 8 Stream API,
I wanted to write a program to search for even numbers in integer arrays with IntStream, so I came up with this solution,
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
IntStream.of(numbers).filter(i -> i%2 == 0).forEach(System.out::println);
and it works right for me.
but how can I change filterto skip specific array indices from validation numbers?
eg,
if I want to skip numbers[1]from checking, if it is or not, then what should I do?
because iin the filter these are the values of the elements of the array, not their indices.
can this be done?
source
share