Re: Clone java collection & static variable??



Hello Tom,

Thanks for your repsonse, and sorry for the messy code.

Not it doesn't. Your code is consistent with shallow copies. It is
however very difficult to follow.

I thought a shallow copy would be when you call clone() on an array, it
creates a new object reference to the array, but the reference inside
the array stay the same? The output in the program shows otherwise.
It also clone object references inside the array. Isn't that the
behaviour of deep copy?

So, if a shallow copy on a java collection will clone the object
reference to the collection and clone the object reference it contains,
then a deep copy of java collection would be the above plus clone any
object references inside the object in the array. Ex:
class Entry{
int val
EntryList e_list // deep copy will also clone this?

Thanks

.



Relevant Pages

  • Re: Clone java collection & static variable??
    ... creates a new object reference to the array, but the reference inside the array stay the same? ... It also clone object references inside the array. ... A deep copy of a List or an array creates a new List or array with references to equivalent but values in each entry. ... reference to the collection and clone the object reference it contains, then a deep copy of java collection would be the above plus clone any object references inside the object in the array. ...
    (comp.lang.java.programmer)
  • Re: MemberwiseClone() doesnt like arrays?
    ... separate array. ... will need to write Clone yourself, ... I have lots of classes inheriting from those ... classes, adding more members still. ...
    (microsoft.public.dotnet.languages.csharp)
  • How do you store a stoopid array in the stoopid ViewState?
    ... Object reference not set to an instance of an object. ... An unhandled exception occurred during the execution of the ... Is there any way to create an immediate array in C#? ... public void Page_Init (object sender, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Whats the use of cloning?
    ... Here's what ur clone method could look like to return a deep clone of ... the integer array: ... > values of the original object, but the changes of the cloned object should ...
    (comp.lang.java.programmer)
  • Submitting an Array to a Webservice.
    ... I've got an order entry webservice whose WSDL looks like this: ... So my problem is how do I fill the array of Items? ... Object reference not set to an instance of an object. ... webservice array equal to it but I'm having a heck of a time even with that. ...
    (microsoft.public.dotnet.framework.webservices)