Just curious:
Someone knows why the method System.arraycopy
uses Object
as type for src
and dest
? Would be perfectly possible to use Object[]
instead?
Why define:
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
instead of
arraycopy(Object[] src, int srcPos, Object[] dest, int destPos, int length)
?
Primitive array types like boolean[]
and double[]
do not extend Object[]
but they do extend Object
This method allows you to copy any type of array, so the type is Object.
int[] a =
int[] b =
System.arraycopy(a, 0, b, 0, a.length);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments