About 7,080,000 results
Open links in new tab
  1. How do I copy an object in Java? - Stack Overflow

    Mar 23, 2012 · Basic: Object Copying in Java. Let us Assume an object- obj1, that contains two objects, containedObj1 and containedObj2. shallow copying: shallow copying creates a new instance of the …

  2. How to clone a Java object with the clone () method

    Sep 28, 2011 · The clone() method of Object (which will eventually be called when all superclasses obey the contract) makes a shallow copy and takes care of the correct runtime type of the new object. …

  3. java - How do you make a deep copy of an object? - Stack Overflow

    50 You can do a serialization-based deep clone using org.apache.commons.lang3.SerializationUtils.clone(T) in Apache Commons Lang, but be …

  4. How does the Java clone method work? - Stack Overflow

    Feb 10, 2017 · 13 java cloning is field by field copy i.e. as the Object class does not have idea about the structure of class on which clone () method will be invoked. 1) If the class has only primitive data type …

  5. How does Cloneable work in Java and how do I use it?

    Apr 30, 2021 · I would like to know the following: Cloneable means we can have a clone or a copy of objects, by implementing the Cloneable interface. What are the advantages and disadvantages of …

  6. How do I clone a generic List in Java? - Stack Overflow

    Also, ArrayList.clone will only do a shallow clone, so mutable objects in the list won't be cloned using that method either.

  7. java - How to properly override clone method? - Stack Overflow

    Feb 24, 2010 · If a class and all its superclasses call super.clone() within their clone methods, a subclass will generally only have to override clone() if it adds new fields whose contents would need …

  8. ¿Cuál es la manera correcta de usar el método clone para copiar una ...

    Quiero copiar una lista en Java, y encontré un método llamado clone, el cual sirve para eso, y funciona bien, pero creo que no lo estoy usando correctamente, ya que me sale una advertencia en Eclip...

  9. Clone() vs Copy constructor- which is recommended in java

    Sep 25, 2013 · Clone is broken, so dont use it. THE CLONE METHOD of the Object class is a somewhat magical method that does what no pure Java method could ever do: It produces an …

  10. java - Recommended solution for deep cloning/copying an instance ...

    Java Deep Cloning Library - using reflection - in cases when the classes or the objects you want to clone are out of your control (a 3rd party library) and you can't make them implement Serializable, or in …