I made my class Cloneable but I still get 'Can't access protected method clone. Why?

Q

I made my class Cloneable but I still get 'Can't access protected method clone. Why?

✍: Guest

A

Yeah, some of the Java books, in particular "The Java Programming Language", imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that's not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn't do anything special and just calls super.clone().

2013-02-07, 1978👍, 0💬