I am looking for a compressed way to filter items in a list by a specific index. My input example is as follows:
List<Double> originalList = Arrays.asList(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0); List<Integer> filterIndexes = Arrays.asList(2, 4, 6, 8);
I want to filter out the elements at index 2 , 4 , 6 , 8 . I have a for loop that skips the elements matching the index, but I was hoping there would be an easy way to do this with threads. The final result will look like this:
List<Double> filteredList = Arrays.asList(0.0, 1.0, 3.0, 5.0, 7.0, 9.0, 10.0);
java java-8 java-stream
Vedanth
source share