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
  • 4
    You use the same technique to convert an `Arraylist` to `X[]`, no matter what `X` is. Even if you need to use `[]` to write out `X` properly. – Karl Knechtel Nov 12 '21 at 14:06
  • 2
    Does this answer your question? [From Arraylist to Array](https://stackoverflow.com/questions/7969023/from-arraylist-to-array) – Karl Knechtel Nov 12 '21 at 14:06

1 Answers1

7

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

yyyy
  • 593
  • 2
  • 10