这里说的数组是内置数组,类似 int a[] = new int[3] 这样的数组。
摘录
The members of an array type are all of the following:
The
public
final
fieldlength
, which contains the number of components of the array.length
may be positive or zero.The
public
methodclone
, which overrides the method of the same name in classObject
and throws no checked exceptions. The return type of theclone
method of an array type T[]
is T[]
.A clone of a multidimensional array is shallow, which is to say that it creates only a single new array. Subarrays are shared.
All the members inherited from class
Object
; the only method ofObject
that is not inherited is itsclone
method.
总结
有一个正整数属性 length
有一个方法clone,返回一个克隆的数组。
继承自Object,除了clone,其他方法都没有重写。
补充
内置数组受编译支持,继承自Object,却没有自己的显式类名。调用getClass方法可以输出运行时类签名。官网也有说明,摘录:
class Test {
public static void main(String[] args) {
int[] ia = new int[3];
System.out.println(ia.getClass());
System.out.println(ia.getClass().getSuperclass());
}
}
This program produces the output:
class [I
class java.lang.Object