How can I declare an array of byte arrays with a limited size for the array? This is what I was thinking but it's not working and I couldn't find anything.
private Integer number =10000;
private byte[] data[];
data = new byte[][number];
Something like this?
private byte[][] data; // This is idiomatic Java
data = new byte[number][];
This creates an array of arrays. However, none of those sub-arrays yet exist. You can create them thus:
data[0] = new byte[some_other_number];
data[1] = new byte[yet_another_number];
...
(or in a loop, obviously).
Alternatively, if they're all the same length, you can do the whole thing in one hit:
data = new byte[number][some_other_number];
may be you need a 2-d array
private byte[][] data = new byte[10][number];
that declares 10 byte arrays each of size number
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With