JDK11源码学习04 | Cloneable接口

JDK11源码学习04 | Cloneable接口

package java.lang;

/**
 * A class implements the <code>Cloneable</code> interface to
 * indicate to the {@link java.lang.Object#clone()} method that it
 * is legal for that method to make a
 * field-for-field copy of instances of that class.
 *
 * 类实现Cloneable接口以向该Object.clone()方法指示该方法合法地为该类的实例制作字段的字段副本。
 *  
 *
 * Invoking Object's clone method on an instance that does not implement the
 * <code>Cloneable</code> interface results in the exception
 * <code>CloneNotSupportedException</code> being thrown.
 *
 * 在未实现Cloneable接口的实例上调用Object的clone方法会 导致 CloneNotSupportedException抛出异常。
 *
 * 
 * By convention, classes that implement this interface should override
 * {@code Object.clone} (which is protected) with a public method.
 * See {@link java.lang.Object#clone()} for details on overriding this
 * method.
 *
 * 按照惯例,实现此接口的类应使用公共方法覆盖 Object.clone(它是 protected 的)。
 *
 * 
 * Note that this interface does <i>not</i> contain the {@code clone} method.
 * Therefore, it is not possible to clone an object merely by virtue of the
 * fact that it implements this interface.  Even if the clone method is invoked
 * reflectively, there is no guarantee that it will succeed.
 *
 * 请注意,这个接口并没有包含克隆方法。因此,仅仅通过实现该接口的事实来克隆对象是不可能的。
 * 即使反射调用clone方法,也无法保证它会成功。
 *
 *
 * @author  unascribed
 * @see     java.lang.CloneNotSupportedException
 * @see     java.lang.Object#clone()
 * @since   1.0
 */
public interface Cloneable {
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值