clone()方法在Object类中默认不可见,那么它如何不为Array类型提供错误?
这是否意味着有一个名为int []的类型,其实现是用java编写的,如果是,在哪里找到它?
如果是写的那么为什么不写完呢?
我的意思是为什么不正确地实现每个方法而不仅仅是来自ObjectClass 的行为.
int[] a ={1,2,3};
Object object = new Object();
object.clone();//Does not compile since clone is protected.
a.clone();// allowed as this method is from int[]
Run Code Online (Sandbox Code Playgroud)