public interface Cloneable
Cloneable
接口的
Object.clone()
方法表明,该方法对该类的实例字段复制使一场是合法的。
调用对象的克隆方法对一个不在例外CloneNotSupportedException
被实施Cloneable
界面结果实例。
按照惯例,实现此接口的类必须重写Object.clone(这是保护)与一个公共方法。看到在重写此方法的细节Object.clone()
。
注意,这个接口是空不包含clone方法。因此,它是不可能的克隆一个对象仅仅凭借的事实,它实现了这个接口。即使克隆方法被调用时进行反思,也不能保证它会成功。
CloneNotSupportedException
,
Object.clone()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.