The For loop replicates one by one: The For loop is flexible, but the code is not concise enough.
System.arraycopy:System.arraycopy () source code. You can see that it is the native method: The native keyword describes its method of modification as an original ecological method, and the corresponding implementation of the method is not in the current file, but in a file implemented in other languages such as C and C + +. The native method can be likened to a Java program's interface to a C program. ( optimal )
public static native void Arraycopy (Object src, int Srcpos,
System.copyof:copyOf is not the system method, but the arrays method, the following is the source code, you can see the Arraycopy method is essentially called. , then its efficiency must be inferior to Arraycopy's
| 123456 |
public static int[] copyOf(int[] original, int newLength) { int[] copy = new int[newLength]; System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); return copy;} |
With the Clone method: Clone, the object returned is "" and requires a cast. The general use of clone efficiency is the worst
Several methods of array copying in Java language