O'Reilly logo
  • Kunal Sumbly thinks this is interesting:

.flatMap(i -> numbers2.stream() .map(j -> new int[]{i, j}) )

From

Cover of Java 8 in Action: Lambdas, streams, and functional-style programming

Note

The number 2 stream returns the stream on [3,4] and the map on it is actually putting element of number2 into a new int [] with number1 element. i.e. we are actually getting a Stream<Integer []> and with 6 arrays [1,3] , [1,4] , [2,3] ... [3,3] and [3,4] which is fed to the flatmap to get a consistent stream of a single combined array which is a union of all those 6 arrays [(1,3),(1,4),... (3,3), (3,4)]