This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
Hi! What's the difference between cloning and assignment? example: int p = new int; int p2 = (int)p.clone(); VS int p = new int; int p2 = p; Thanks in advance.
posted 15 years ago
in this case there is no difference. Its like copying the reference of one array to another. Array Objects has their own overriden clone() method, which only does shallow copying. i.e. something like assinging the an array reference to another array reference variable. Inorder to get your own clone behaviour, you need to write a public method clone() in your class which must call the protected clone() method inherited from Object method. or you can implement the Cloneable interface. Cheers Siva