System.arrayCopy() copies object or reference to object?

后端 未结 5 572
旧巷少年郎
旧巷少年郎 2020-12-16 03:04

I am having a final class NameAndValue. I copied an array of NameAndValue objects using System.arrayCopy() and when i changed a

5条回答
  •  难免孤独
    2020-12-16 03:38

    As far as I know arraycopy is a shallow copy. Which means the new array will reference to the addresses of the elements in the old array. So if you adjust a value in one of them, it will reflect on both

提交回复
热议问题