Does clone() deep-copy arrays of integers?

If my class has an arrayn of integers as an attribute then do I need to override its clone() method to make a deep copy of the array or is a new chunk of memory allocated to the array attribute of the clone?

Thanks in advance,


  • It will not deep-copy, you'll need to override clone() :) This is because an array of ints is still an object, and the class references it, so the reference will be copied but not the actual object.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion