Declare a byte array in Java

How to declare a finite byte array? That's what I'm thinking, but it doesn't work. I can't find anything

private Integer number =10000;
private byte[] data[];
data = new byte[][number];

Solution

Such a thing

private byte[][] data;  // This is idiomatic Java

data = new byte[number][];

This creates an array However, none of these subarrays exist You can create them:

data[0] = new byte[some_other_number];
data[1] = new byte[yet_another_number];
...

(or a cycle, obviously)

Or, if they are the same length, you can do everything in one hit:

data = new byte[number][some_other_number];
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>