r*****u 发帖数: 2013 | 1 without using Object.clone()? |
m******t 发帖数: 2416 | 2
I can't think of any other generic way except of using reflection
to traverse the member variables. But that's pretty hacky, and
slow as well ...
【在 r*****u 的大作中提到】 : without using Object.clone()?
|
m******t 发帖数: 2416 | 3
BTW, it just occured to me that if you don't care about the color
of the object, then a regular office copier might work very well...
【在 m******t 的大作中提到】 : : I can't think of any other generic way except of using reflection : to traverse the member variables. But that's pretty hacky, and : slow as well ...
|
r*****u 发帖数: 2013 | 4 The problem of using reflection is that you can not copy the
private field of the superclass.
【在 m******t 的大作中提到】 : : BTW, it just occured to me that if you don't care about the color : of the object, then a regular office copier might work very well...
|
m******t 发帖数: 2416 | 5
maybe this would work?
java.lang.reflect.ReflectPermission
【在 r*****u 的大作中提到】 : The problem of using reflection is that you can not copy the : private field of the superclass.
|
c*****t 发帖数: 1879 | 6 object serialization.
【在 r*****u 的大作中提到】 : without using Object.clone()?
|
r*****u 发帖数: 2013 | 7 This only applies to serilizable object, right?
\【 在 coconut (coconut) 的大作中提到: 】 |
r*****s 发帖数: 985 | 8 first, it depends on what "copy" means here. does your "copy" here mean
creating another object without calling its constructor?
generally, if you don't like the generic Object.clone(), why not
override it? You can provide your own way of "copy" in this way.
【在 r*****u 的大作中提到】 : This only applies to serilizable object, right? : \【 在 coconut (coconut) 的大作中提到: 】
|