Skip to content

Instantly share code, notes, and snippets.

@mgandin
Created May 17, 2018 13:51
Show Gist options
  • Save mgandin/9df8fff38fb8fb18e89cf4d5d16eb66e to your computer and use it in GitHub Desktop.
Save mgandin/9df8fff38fb8fb18e89cf4d5d16eb66e to your computer and use it in GitHub Desktop.
Don't do that at home kid, it burns !
import static java.util.Arrays.asList;
import java.util.List;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
List<Integer> numbers = asList(1, 2, 3, 4, 5);
int[] factor = {2};
Stream<Integer> integerStream = numbers.stream()
.filter(i -> i % 2 == 0)
.map(i -> i * factor[0]);
factor[0] = 3;
integerStream
.forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment