public class Demo { public static void main(String[] args) { String[] arr = new String[] { "P","Q", "R", "S", "T"}; System.out.println("Initial array..."); for (int i = 0; i<arr.length; i++) System.out.println(arr[i]); int len = arr.length; String[] arr2 = new String[len]; System.arraycopy(arr, 0, arr2, 0, arr.length); System.out.println("New array...copied"); for (int i = 0; i<arr2.length; i++) System.out.println(arr2[i]); } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more