Consider the following from Effective Java Item 11 (Override clone judiciously) where Josh Bloch is explaining what is wrong with the clone()
contract .
There are a number of problems with this contract. The provision that “no constructors are called” is too strong. A well-behaved clone method can call constructors to create objects internal to the clone under construction. If the class is final, clone can even return an object created by a constructor.
Can someone explain what Josh Bloch is saying in the first paragraph by "If the class is final
, clone
can even return an object created by a constructor." What does final
have to do with clone()
here?