它是如何能夠存儲數據量(字節)輸入這樣的: 輸入數據(字節):01 23 45和67 89 10的ArrayList在ArrayList的
在最後的ArrayList行:[[01,23 ,45],[67,89,10]]
// declaration
List<List<Byte>> row = new ArrayList<List<Byte>>();
List<Byte> myBytes = new ArrayList<Byte>();
int j=0;
// code before this defines the arraylengt to cut the buffer in pieces of 3 bytes
// and clears the Mybytes arraylist to be able to fill the buffer with new values
if(arrayLength > 0)
{
myBytes.add(value); // fill first arraylist (buffer) with byte value (for example: 01)
if(arrayLength == 1) // when buffer myBytes is full (with values 01 23 45) write value to position j in the new arraylist
{
row.add(j,new ArrayList<Byte>());
row.set(j,myBytes);
j +=j;
}
arrayLength -= 1; // for cutting the buffer in pieces of 3 bytes
}
謝謝你幫助我!
這已經回答了http://stackoverflow.com/questions/4126272/how-do-i-implement-nested-arraylist – o0rebelious0o