ariestamirra

CopyArray

Apr 3rd, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. public class CopyArray {
  2. public static void main(String args[]) {
  3.     int[] array1 = { 7, 4, 8, 1, 4, 1, 4 };
  4.     int[] array2 = new int[3];
  5.     System.arraycopy(array1,0,array2,0,3);
  6.     System.out.print("Array1 : ");
  7.     for (int i=0; i<array1.length; i++)
  8.         System.out.print(array1[i] + " ");
  9.         System.out.println();
  10.         System.out.print("Array2 : ");
  11.     for (int i=0; i<array2.length; i++)
  12.         System.out.print(array2[i] + " ");
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment