To filter a List
we can use
a1.stream().filter(x->x>6).forEach(System.out::println);
and to filter two lists I used FlatMap
Stream<List<Integer>> s2=Stream.of(a1,a2);
s2.flatMap(x->x.stream()).sorted().filter(x->x>6).forEach(System.out::println);
but I tried filtering in this way for a single List
Stream<List<Integer>> s1=Stream.of(a1);
s1.map(x->x.stream()).filter(x->x>2).forEach(System.out::print);
I got an error--- The operator > is undefined for the argument type(s) Stream<Integer>, int
but when I use the flatMap in the map no error why
Stream<List<Integer>> s1=Stream.of(a1);
s1.flatMap(x->x.stream()).filter(x->x>2).forEach(System.out::print);