送分了:"shallow copy" 和"deep copy" 的区别,越详细越好:)

whales 2002-04-30 03:17:54
The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

英文太次,看不懂。祝节日快乐!
...全文
121 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
whales 2002-04-30
  • 打赏
  • 举报
回复
提问之前搜过了,可惜没有找到。

感谢二位了,很遗憾只能给100分。
xmvigour 2002-04-30
  • 打赏
  • 举报
回复
Patrick_DK(疾风摩郎) :
我还多了150 但离第二颗星太远了 真没劲!
呵呵……
Patrick_DK 2002-04-30
  • 打赏
  • 举报
回复
NND,我还差140分才有一个五角星啊,抢分抢分抢分
xmvigour 2002-04-30
  • 打赏
  • 举报
回复
呵呵……
Patrick_DK(疾风摩郎) 你还真是斑竹作到家了:))
Patrick_DK 2002-04-30
  • 打赏
  • 举报
回复
应该说的是我那个帖子

我去找找看
pengji 2002-04-30
  • 打赏
  • 举报
回复
建议看看thinking JAVA里面讲的很详细!在334页!
简单的说有一个vector 里面都是hashtable
如果调用vector.clone()这样是浅层复制,因为vector中的hashtable还是和前面那个vector中的公用的!
如果调用了vector.clone()同时也扁历了vector中的HASHTABLE是它也CLONE()了一个副本,也就是说前后两个vector是完全不同的对象,那这样的复职就叫深层复制!
xmvigour 2002-04-30
  • 打赏
  • 举报
回复
建议你搜索一下 以前有一个贴子对这个作了很多解释!!!!!!!!!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧