Shallow clone
登录 | 论坛导航 -> 华新鲜事 -> 技术の宅 | 本帖共有 4 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:抽烟看球 (等级:2 - 初出茅庐,发帖:119) 发表:2006-04-07 12:21:21  楼主  关注此帖
能解释一下deep clone and shallow clone 么?
Shallow clone
Shallow clone: if original object's value is changed, and the copy of that object also changes.
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:抽烟看球 (等级:2 - 初出茅庐,发帖:119) 发表:2006-04-07 14:09:15  2楼
多谢!第三个是可以,不过还是有 Note: aaa.java uses unchecked or unsafe operations 难道就没有办法可以避免吗?
Leave it
this warning message just shows that compiler cannot assure correctness of this casting operation as clone() method returns type of object.

It is really programmer's responsibility to avoid any casting failure.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:抽烟看球 (等级:2 - 初出茅庐,发帖:119) 发表:2006-04-09 15:52:11  3楼
is it similar to copy pointer and copy objects in C?
I didnt make my statement clear enuf
in this case, a shallow clone will make an extra copy of Vector object. ( only container object is copied)

however, a deep clone will create memory for Vector object and all String objects inside this Vector. ( container and contained objects are all duplicated)

欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
作者:抽烟看球 (等级:2 - 初出茅庐,发帖:119) 发表:2006-04-10 23:27:12  4楼
so shallow is just assign a reference , am I right
copy object for container, copy referrence for contained object
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 技术の宅 | 返回上一页 | 本主题共有 4 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码