由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - how to copy an Object?
相关主题
copy constructor都什么时候be called啊anonymous innerclass reflection question
Question: reflection and generics怎样用class的string type name 动态生成object?
问个Object.hashCode()的问题这段是什么语法?
有熟悉Java Reflection的吗问一个SCJP 题目
请问有没有generic的array跪求大牛指点Java,看不懂什么意思。
How to know the size of a java object ?这几个函数可以用Generic之类的东西合并么?
请问一个serialize class object下载运行的问题问一个generic的问题吧
Object stream & serilization有啥用处?[转载] Java 1.5 Generic 问题
相关话题的讨论汇总
话题: object话题: copy话题: using话题: reflection话题: without
进入Java版参与讨论
1 (共1页)
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) 的大作中提到: 】

1 (共1页)
进入Java版参与讨论
相关主题
[转载] Java 1.5 Generic 问题请问有没有generic的array
Object比较How to know the size of a java object ?
[合集] 问一个很常见的过程的实现请问一个serialize class object下载运行的问题
Java里面有没有可能写个带generic parameter的class对built-in type也适用?Object stream & serilization有啥用处?
copy constructor都什么时候be called啊anonymous innerclass reflection question
Question: reflection and generics怎样用class的string type name 动态生成object?
问个Object.hashCode()的问题这段是什么语法?
有熟悉Java Reflection的吗问一个SCJP 题目
相关话题的讨论汇总
话题: object话题: copy话题: using话题: reflection话题: without