File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Object clone()" Watch "Object clone()" New topic

Object clone()

Brett Anthoine

Joined: Mar 12, 2002
Posts: 27
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.
[ May 22, 2002: Message edited by: vijay kashyap ]
Brett Anthoine

Joined: Mar 12, 2002
Posts: 27
Thanks you vijay.
I agree. Here's the link:
subject: Object clone()
It's not a secret anymore!