Java-arraycopy

arraycopy

The arraycopy( ) method can be used to copy quickly an array of any type from one place to another. This is much faster than the equivalent loop written out longhand in java.

Program 

Program Source

public class Javaapp {
 
    public static void main(String[] args) {
     
        int[] array_v1 = {10,20,30,40,50,60};
        int[] array_v2 = new int[4];
     
        System.arraycopy(array_v1,2,array_v2,1,3);
     
        for(int i=0;i<array_v2.length;i++)
        {
            System.out.println("array_v2 ["+i+"] = "+array_v2[i]);
        }
    }
}

Leave a Comment