This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Object clone() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Object clone()" Watch "Object clone()" New topic
Author

Object clone()

Brett Anthoine
Greenhorn

Joined: Mar 12, 2002
Posts: 27
Hello,
I'm trying to get an exact copy of an object's instance. example

The problem is the compiler says clone() is protected. I'm confused.


Brett Anthoine<br />"640k should be enough for anybody."
Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74
Hi Brett,
You have to supply cloning method for your TestClass.
As the clone method is protected in Object class which is your super class( if you are not extending any other class in TestClass) hence you cannot use clone method without providing definition for it.
Regards,
Vijay
[ May 22, 2002: Message edited by: vijay kashyap ]
Brett Anthoine
Greenhorn

Joined: Mar 12, 2002
Posts: 27
Thanks you vijay.
 
Consider Paul's rocket mass heater.
 
subject: Object clone()
 
Similar Threads
a question
null
class references..
Confusing code from JQ++
Interview question