I would like to know how to properly reference an Array Of An Array of Bytes
I have some primitive data types, which are say a couple of megabytes large each
byte[] data1, data2, data3, data4 ... ,data10;
data1 = ..(something 2MB big)
data2 = ..(something 2MB big)
data3 = ..(something 2MB big)
.
.
data10 = ..(something 2MB big)
I want to arrange these 10 byte[]'s into an array (this is where my code goes wrong)
private byte[] arrayofdatas[];
arrayofdatas[1] = data1;
arrayofdatas[2] = data2;
.
.
etc.
I've tried this but when the line arrayofdatas[1] = data1 goes, I get a null pointer exception Please help me clean up the code, it has been very hard to search about this exact problem.
P.S. I need the data types to remain as byte[]. Please do not convert them into Strings.
Edit: I need the variable arrayofdatas to be a field variable. I'm having problems because I don't know how to declare it as field. All your answers have made it local and used 'new'. Another thing.. I have made '10' an abitrary number of byte[]'s that I want. Ultimately I want this array to be unbounded. Is there a way to add on to the array as more byte[]s are added, so that there could be a arrayofdata[500] in the future, without having to declare the size at the start?