| Author |
Cloneable
|
Arjun Reddy
Ranch Hand
Joined: Nov 10, 2007
Posts: 622
|
|
When to use a cloneable class and why? Can a final class be cloneable? If not, why? If yes, why? Can anyone please answer this question? Thanks. [ November 13, 2008: Message edited by: Arjun Reddy ]
|
Be Humble... Be Nice.
|
 |
Harshit Rastogi
Ranch Hand
Joined: Apr 15, 2008
Posts: 131
|
|
Originally posted by Arjun Reddy: When to use a cloneable class and why? Can a final class be cloneable? If not, why? If yes, why? Can anyone please answer this question? Thanks. [ November 13, 2008: Message edited by: Arjun Reddy ]
About Cloning CLoning of ojbect is only possible if the Class implements Cloneable interface. So an true final class will not want to make its objects clone and it wont implement the interface.
|
<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
What is wrong with a final class being cloned? If you mean immutable, there is no point in cloning immutable objects, so immutable classes don't usually implement the Cloneable interface. A lot of people think cloning is a bad idea; see for example "Effective Java" by Joshua Bloch.
|
 |
 |
|
|
subject: Cloneable
|
|
|