Alex schreef:
Hi,
I am having trouble with the following: I wish to have a list of lists
of type Double called A. I then have a separate List of Doubles called
B which i wish to add to A. I then want to be able to clear B and reuse
it without clearing what I have added to A.
Currently my code looks like:
for(int i=0;i<seqLength;i++)
{
B.clear();
for(int j=i+1;j<seqLength;j++)
{
if(fourGameteTest(i,j))
{
B.add(segPositions.get(j));
}
}
A.get(i).add(B);
A.get(i).addAll(B);
}
However, it seems that due to, I guess the element held in A being a
reference to the same place as B, when B is cleared A ends up having no
elements. How can I do this so as to be able to reuse B but not lose
what I have stored in A?
If you made this code generic, it would give a type error: You are
adding B to the ith list in A, instead you probably want to add all
values of B, see above.
H.
--
Hendrik Maryns
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
--------------enig13D766A4299F198A3B856CA7
Content-Type: application/pgp-signature
Content-Disposition: inline;
filename="signature.asc"
Content-Description: OpenPGP digital signature
X-Google-AttachSize: 190