Love all, trust a few, do wrong to none.
Adrian Burkett wrote:What does line 66 do ? Do you really want to do that ?
Love all, trust a few, do wrong to none.
chaitanya karthikk wrote:Hi all, I read this article about how to do a deep copy but I am unable to do it.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
chaitanya karthikk wrote:This is my code...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Love all, trust a few, do wrong to none.
I started it as a mental exercise. How are developers doing it now a days then?Winston Gutkowski wrote:
chaitanya karthikk wrote:Hi all, I read this article about how to do a deep copy but I am unable to do it.
It might be worth pointing out that the article in question is 13 years old. I don't think anyone would recommend this method now (and the author himself acknowledges that it's fearfully slow).
However, if this is just a mental exercise, best of luck.
Winston
Love all, trust a few, do wrong to none.
Love all, trust a few, do wrong to none.
chaitanya karthikk wrote:Thanks I will not repeat.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Hi William, thanks for your reply. I read somewhere in coderanch itself that we should not use BeanUtils to perform a deep copy because it causes problems. I don't remember the actual reason. But I am sure that BeanUtils are used in large frameworks like struts.William P O'Sullivan wrote:You could also use this:
http://commons.apache.org/beanutils/api/org/apache/commons/beanutils/BeanUtils.html#cloneBean(java.lang.Object)
WP
Love all, trust a few, do wrong to none.
Hi Mr. Martin, I dint understand why you added the if condition even though you explained the reason. I could not understand it. Can you please explain?Martin Vajsar wrote:Chaitanya, I'd add the following lines to the code in your last post:
The reason is that if you ever subclass the Student class and forget to override the clone() method, the subclass instance would get silently converted into the Student instance by the clone() method. As there is no mechanism to force subclass to override a method, it is better to have at least the runtime check.
Love all, trust a few, do wrong to none.
Love all, trust a few, do wrong to none.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Love all, trust a few, do wrong to none.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Don't get me started about those stupid light bulbs. |