Solved

# Indexing ArrayLists of Vectors (AL[i] = new vector();)

Posted on 2007-04-01

Is it possible to index ArrayLists? I want to have a number of ArrayLists each consisting of a vector....

ArrayList al = new ArrayList();

for (int k=0; k<Bins;k++)

{

al[k] = new vector();

for (int l=k*Binsize;l<(k*Binsize)+Binsize;l++)

{

al[k].add(Entry[l]);

}

}

To attempt to clarify the above, Entry[] is an array of integers. I want to split that array up into 'Bins', each of which consists of a vector of entries from the array. So, if Entry[6] = {1 2 3 4 5 6), and I want 3 Bins, I want to create 3 ArrayLists consisting of vectors so that al[0] is a vector {1 2}, al[1] is a vector {3 4} and al[2] is a vector {5 6}. I want to use vectors because I'll be doing a lot of mathematical comparison and merging and vectors/ArrayLists seem like the friendliest animals to manipulate in this way.

If I haven't confused you to the point of causing you to scream at your monitor and throw things at your pets, I'd greatly appreciate any help. Thanks.

Jason