lucia.roibal@[EMAIL PROTECTED]
wrote:
> Say, I do the follow,
>
> Date d=new Date();
>
> ArrayList<Data> alist= new ArrrayList();
>
> alist.add(d);
>
> //modify d
>
> will the element d in the alist also modified?
Java almost never does a deep copy, any time. Even .clone() does not
deep-copy, it does a shallow copy.
When you add d to alist, you add d, the reference, nothing else. Java
always uses semantics which are equivalent to pointers in C++.
Vector<Date*> alist = Vector<Date*>();
Date *d = new Date();
alist.add(d);
Or something like that, it's been a long time since C++.....


|