0
Can someone explain the last line of these program system.Arraycopy please
int[] biggerArray=size1>size2 ? array1:array2; int[] smallerArray=size1<=size2 ? array1:array2; int[] summedArray=new int[biggerArray.length]; System.arraycopy(biggerArray,0,summedArray,0,biggerArray.length);
3 odpowiedzi
+ 5
From Oracle's Java documentation:
https://docs.oracle.com/javase/7/docs/api/java/lang/System.html
"""
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.
"""
In your code elements of biggerArray are copied to summedArray which has same length as biggerArray.
+ 4
Here is an example.
https://code.sololearn.com/c5FV2BHhaHw6/?ref=app
+ 2
From source array 'biggerArray' of index 0 to bigger Array.length values are copied to destination array summedArray from index 0 (to biggerArray.length..)
Its a method to copy subarray from a source array to destination array from specified locations..