g*****g 发帖数: 34805 | 1 Folks, I am confused when one needs to implement clone interface
in java, can't java just copy memory like C++? | c*****t 发帖数: 1879 | 2 You can't do copy memory on a DAG. The result would be a tree.
You can't copy undirected graph or direct graph w/ circular
structures.
【在 g*****g 的大作中提到】 : Folks, I am confused when one needs to implement clone interface : in java, can't java just copy memory like C++?
| m******t 发帖数: 2416 | 3 IMHO, the actual reason is Java has to let the programmer decide
whether to make deep or shallow copy while cloning. In some cases,
a hybrid of deep and shallow copy is also possible.
Also, while it's not hard for Java to provide a generic clone utility,
it would have to be based on reflection (similar to how serialization
works), which could be faily expensive operations. |
|