How to print a List of Arrays (with elements) using Java 8 Streams?

Viewed 3921
public static void main(String[] args) {
    List<Integer> numbers1 = Arrays.asList(1,2,3);
    List<Integer> numbers2 = Arrays.asList(3,4);

    List<int[]> intPairs = numbers1.stream()
            .flatMap(i -> numbers2.stream()
                    .filter(j -> (i+j)%3 == 0)
                    .map(j -> new int[]{i,j}))
                    .collect(Collectors.toList());

    intPairs.stream().forEach(System.out::println);
}

For the above code, I am getting output as:

[I@214c265e
[I@448139f0

But my expectation is to get [(2, 4), (3, 3)].

Could you please guide me to achieve this?

1 Answers
Related