Explicitly extending Object class and calling clone method of object throwing error
Posted
by Suresh S
on Stack Overflow
See other posts from Stack Overflow
or by Suresh S
Published on 2010-06-10T07:02:33Z
Indexed on
2010/06/10
7:12 UTC
Read the original article
Hit count: 229
i tried the following code for cloning the object. while compiling it shows clone is protected and cannot be accessed, but i had extended Object class, hence the clone method will be public to my class . please explain me the reason.
class storeDate extends Object {
public static void main(String[] args)
{
storeDate d = new storeDate();
Object o = (storeDate)d;
o.clone():
}
}
© Stack Overflow or respective owner