| Author |
clone
|
mo shaik
Greenhorn
Joined: Jul 17, 2007
Posts: 23
|
|
hai,
|
 |
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
|
|
Hi, The clone method is used in cases where you have an object that you need to create a copy of. clone method will return the new object with the same source state. Where as creating an object using "new" will give completely new object. Constructor is not called while cloning takes place. Thanks,
|
cmbhatt
|
 |
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
|
|
Avoid clone: Make your classes uncloneable. Java's object-cloning mechanism allows an attacker to instantiate a class without running any of its constructors. To make your class uncloneable, just define the following method in each of your classes: If you really need to make your class cloneable, then there are some protective measures you can take to prevent attackers from redefining your clone method. If you're defining your own clone method, just make it final. If you're not, you can at least prevent the clone method from being maliciously overridden by adding the following:
|
 |
mo shaik
Greenhorn
Joined: Jul 17, 2007
Posts: 23
|
|
|
|
 |
Bert Bates
author
Sheriff
Joined: Oct 14, 2002
Posts: 8712
|
|
|
clone() isn't on the exam
|
Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
|
 |
 |
|
|
subject: clone
|
|
|