Object在其子类中不能调用clone()方法

查看Object源码中clone()方法的实现:

protected native Object clone() throws CloneNotSupportedException;

clone()方法的访问权限是protected,因为你的例程不是在java.lang包中,protected类型只能在本包和子类中访问。

猜你喜欢

转载自blog.csdn.net/m0_37732829/article/details/81941617