system arraycopy 28 29 method in java

Solutions on MaxInterview for system arraycopy 28 29 method in java by the best coders in the world

showing results for - "system arraycopy 28 29 method in java"
Monica
16 Feb 2020
1public class SystemArraycopyMethodExample
2{
3   public static void main(String[] args)
4   {
5      int[] arrOne = {2,4,6,8,10,12,14,16,18,20};
6      int[] arrTwo = {1,3,5,7,9,11,13,15,17,19};
7      int[] sourceArr, sourcePosition, destinationArr[], destinationPosition, len;
8      sourceArr = arrOne;
9      sourcePosition = 2;
10      destinationArr = arrTwo;
11      destinationPosition = 5;
12      len = 4;
13      // printing elements of source array
14      System.out.println("Source array : ");
15      for(int a = 0; a < arrOne.length; a++)
16         System.out.print(arrOne[a] + " ");
17      System.out.println("");
18      System.out.println("sourcePosition : " + sourcePosition);
19      // print elements of destination array
20      System.out.println("Destination array : ");
21      for(int a = 0; a < arrTwo.length; a++)
22         System.out.print(arrTwo[a] + " ");
23      System.out.println("");
24      System.out.println("destinationPosition : " + destinationPosition);
25      System.out.println("Length : " + len);
26      // system.arraycopy method in java
27      System.arraycopy(sourceArr, sourcePosition, destinationArr, destinationPosition, len);
28      // printing final array
29      System.out.println("Final array : ");
30      for(int a = 0; a < arrTwo.length; a++)
31         System.out.print(arrTwo[a] + " ");
32   }
33}