What's the difference between deep copy and shallow copy? (深拷贝与浅拷贝有什么区别)

2023-07-06   


  浅拷贝是指将对象中的数值类型的字段拷贝到新的对象中,而对象中的引用型字段则指复制它的一个引用到目标对象。如果改变目标对象中引用型字段的值他将反映在原是对象中,也就是说原始对象中对应的字段也会发生变化。深拷贝与浅拷贝不同的是对于引用的处理,深拷贝将会在新对象中创建一个新的和原是对象中对应字段相同(内容相同)的字段,也就是说这个引用和原是对象的引用是不同的,我们在改变新对象中的这个字段的时候是不会影响到原始对象中对应字段的内容



相关内容:

  1. What's the difference between an interface and abstract class? (接口与抽象类有什么区别)
  2. what is the difference between ext2 and ext3
  3. 软件测试LoadRunner面试题:What is the difference between standard log and extended log?
  4. 软件测试LoadRunner面试题:What is correlation? Explain the difference between automatic correlation and manu
  5. 软件测试LoadRunner面试题:What is the difference between Overlay graph and Correlate graph?