Does clone() deep-copy arrays of integers? - Programmers Heaven

Howdy, Stranger!

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

Categories

Does clone() deep-copy arrays of integers?

zeolitezeolite Posts: 78Member
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,
Dan

Comments

  • Dessimat0rDessimat0r Posts: 6Member
    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.