D
Dan
I have an object that I want to add to an ArrayList.
However, I don't know ahead of time how many objects I
will need to add to the list. Therefore, I had built a
function that created an instace of the object, set its
properties, and then added it to the ArrayList. The
function would then adjust the properties of the object
and again add that object to the ArrayList. The problem I
am having is that the changes I make to, what I thought
would be object 2, are also reflected in object 1 when I
retrieve it from the ArrayList. Does the add method of the
ArrayList pass the object by reference or by value? Does
anyone know how to get around this?
Thanks for the help!
However, I don't know ahead of time how many objects I
will need to add to the list. Therefore, I had built a
function that created an instace of the object, set its
properties, and then added it to the ArrayList. The
function would then adjust the properties of the object
and again add that object to the ArrayList. The problem I
am having is that the changes I make to, what I thought
would be object 2, are also reflected in object 1 when I
retrieve it from the ArrayList. Does the add method of the
ArrayList pass the object by reference or by value? Does
anyone know how to get around this?
Thanks for the help!