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);

11th Oct 2020, 12:49 PM
Aditi Bais
Aditi Bais - avatar
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.
11th Oct 2020, 12:58 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
11th Oct 2020, 12:59 PM
Avinesh
Avinesh - avatar
+ 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..
11th Oct 2020, 12:58 PM
Jayakrishna 🇮🇳