1. Arraycopy method (array copy)
1 Public Static void arraycopy (object src,int srcpos,object dest,intint length)
Copies an array from the specified array, starting at the specified position and ending at the specified position in the destination array.
Parameters:
SRC-source Array
Srcpos-Starting position in the source array
Dest-Destination Array
Destpos-start position in the target data
Length-The number of array elements to copy
2. code example:
1 Packagecn.itcast_03;2 3 Importjava.util.Arrays;4 5 /*6 * The System class contains some useful class fields and methods. It cannot be instantiated. 7 * 8 * Method:9 * public static void GC (): Runs the garbage collector. Ten * public static void exit (int status): Terminates the currently running Java virtual machine. The parameter is used as a status code; By convention, a status code other than 0 indicates an abnormal termination. One * public static Long Currenttimemillis (): Returns the current time in milliseconds A * public static void Arraycopy (Object src,int srcpos,object dest,int destpos,int length) - * Copies an array from the specified source array, starting at the specified position and ending at the specified position in the destination array. - */ the Public classSystemdemo { - Public Static voidMain (string[] args) { - //Defining Arrays - int[] arr = {11, 22, 33, 44, 55 }; + int[] arr2 = {6, 7, 8, 9, 10 }; - + //please look at the meaning of this code ASystem.arraycopy (arr, 1, ARR2, 2, 2); at - System.out.println (arrays.tostring (arr)); - System.out.println (arrays.tostring (ARR2)); - } -}
The results are as follows:
Java Basics Hardening The Arraycopy () method of the 86:system class (array copy)