Hugh
Hugh

Reputation: 1212

Quickest way of storing a byte array in an array?

I was wondering what is the quickest way of storing a byte[] with an integer index in java without using Maps, TreeMap, ArrayLists etc.

i.e. not like this:

private Map<Integer, byte[]> example = new TreeMap()

Upvotes: 2

Views: 205

Answers (3)

BalusC
BalusC

Reputation: 1109865

Quickest way would be an ArrayList<byte[]>, or you want or not. A byte[][] isn't going to work as you can then hold only 28-1 arrays, not 232-1 as you could with an integer index which you explicitly mentioned in your question.

Upvotes: 1

Mark Byers
Mark Byers

Reputation: 839254

How about byte[][] and resize as appropriate? Not as good as an ArrayList but you banned that...

Upvotes: 0

DNNX
DNNX

Reputation: 6255

private byte[][] example;
example = new byte[][ARRAYS_COUNT];
example[0] = new byte[10];
example[1] = new byte[20];
...

Upvotes: 2

Related Questions