VOOZH about

URL: https://www.geeksforgeeks.org/java/system-arraycopy-in-java/

⇱ System.arraycopy() in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

System.arraycopy() in Java

Last Updated : 27 Jun, 2022

java.lang.System class provides useful methods for standard input and output, for loading files and libraries or to access externally defined properties. The java.lang.System.arraycopy() method copies a source array from a specific beginning position to the destination array from the mentioned position. No. of arguments to be copied are decided by an argument. The components at source_Position to source_Position + length - 1 are copied to destination array from destination_Position to destination_Position + length - 1 Class Declaration

public final class System
 extends Object

👁 arraycopy
Syntax : 

public static void arraycopy(Object source_arr, int sourcePos,
 Object dest_arr, int destPos, int len)
Parameters : 
source_arr : array to be copied from
sourcePos : starting position in source array from where to copy
dest_arr : array to be copied in
destPos : starting position in destination array, where to copy in
len : total no. of components to be copied.

Implementation 

Output:

source_array : 10 20 30 40 50 60 70 80 90 100 
sourcePos : 3
dest_array : 15 25 35 45 55 65 75 85 95 105 
destPos : 5
len : 4
final dest_array : 15 25 35 45 55 40 50 60 70 105 
Comment
Article Tags: