In the code, I want to modify variable i
by map()
method:
Integer[] seq = {1, 3, 4, 1, 8, 11};
List<Integer> seqInt = Arrays.asList(seq);
List<Integer> seqFiltered = seqInt.stream().filter(i -> i%2!=0)
.map(i -> i++)
.collect(Collectors.toList());
System.out.println(seqFiltered);
However, it outputs [1, 3, 1, 11]
instead of [2, 4, 2, 12]
which could be obtained from map(i -> i+1)