6

How can I convert Stream<int[]> into int[] without using forEach?

final Stream<int[]> stream = foos.stream()
            .map(foos -> insertQuery(contact, create))
            .map(create::batch)
            .map(Batch::execute); //Batch::execute will return the int[]
0

1 Answer 1

8

Use flatMapToInt

int[] result = stream.flatMapToInt(Arrays::stream).toArray();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.