java stream inner join two lists

Solutions on MaxInterview for java stream inner join two lists by the best coders in the world

showing results for - "java stream inner join two lists"
Veronica
14 Jan 2018
1List<Integer> s1 = Arrays.asList(1, 2);
2List<Integer> s2 = Arrays.asList(1, 3);
3 
4s1.stream()
5  .flatMap(v1 -> s2.stream()
6                   .filter(v2 -> Objects.equals(v1, v2))
7                   .map(v2 -> tuple(v1, v2)))
8  .forEach(System.out::println);
9