Unfortunately, in Java there is no general way to clone an object. Some classes have a public clone()
method that allows you to clone, but there is no common superclass or interface to the public clone()
method. (Actually, since there is no common interface, classes do not even have to call it clone()
, they can call it copy()
or something else.) You could use reflection to see if there is a public clone()
method but it may be redundant.
source share