Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
import java.util.*;
import java.util.stream.Collectors;
public class FilterExample {
public static void main(String[] args) {
List<Integer> nums = Arrays.asList(1,2,3,4,5,6);
List<Integer> even = nums.stream()
.filter(n -> n % 2 == 0)
.collect(Collectors.toList());
System.out.println("Even numbers: " + even);
}
}Coding works best on desktop or with an external keyboard.