Java system.arraycopy Usage Instructions
The Java.lang.System.arraycopy () method copies the array of the specified source array, starting at the specified position, to the specified position in the destination array.
The following is the source code declaration for System.arraycopy:
public static void Arraycopy (object src, int srcpos, object dest, int destpos, int length)
Code Explanation:
Object src: Original array
int Srcpos: Starting from the beginning of the metadata
Object dest: Destination array
int Destpos: Starting position of the target array
int length : The length of the array to copy
For example: We have an array of data byte[] srcbytes = new byte[]{2,4,0,0,0,0,0,10,15,50}; Source Array
byte[] destbytes = new BYTE[5]; Target array
We use System.arraycopy to convert (copy)
System.arraycopy (Srcbytes,0,destbytes, 0,5)
The above code is: Create a one-dimensional empty array, the total length of the array is 12 bits, and then copy the value from the Srcbytes source array from 0 bits to 5th bits into the Destbytes destination array, starting at the No. 0 bit of the destination array.
Then this line of code should run as 2,4,0,0,0,
1 byte[] Srcbytes =New byte[]{2,4,0,0,0,0,0,Ten, the, -};2 byte[] Destbytes =New byte[5];3System.arraycopy (Srcbytes,0, Destbytes,0,5); 4 for(inti =0;i< destbytes.length;i++){5System. out. Print (" -"+destbytes[i]);6}
Operating result: 2-> 4-> 0-> 0-> 0
Java system.arraycopy Usage Instructions