0

I have a method that returns ArrayList<byte[]> and now I want to know if there is a way I can convert it in byte[][]. I've seen so many questions about ArrayList<byte>, but not ArrayList<byte[]>. Can I do that somehow?

ArrayList<byte[]> list = new ArrayList<>()

to

byte [][] b
2
  • 4
    You use the same technique to convert an Arraylist<X> to X[], no matter what X is. Even if you need to use [] to write out X properly. Commented Nov 12, 2021 at 14:06
  • 2
    Does this answer your question? From Arraylist to Array Commented Nov 12, 2021 at 14:06

1 Answer 1

7

list.toArray(new byte[0][]) or list.stream().toArray(byte[][]::new)

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.