/*Assigning Array to Another Array -Iterating each element of the given original array and copy one element at a time b[i] = a[i]; b=a; -Using clone() method int b[] = a.clone(); -Using arraycopy() method int b[] = new int[a.length]; System.arraycopy(a, 0, b, 0, 3); Syntax: public static void arraycopy (Object src, int srcPos, Object dest, int destPos, int length) Parameters: src denotes the source array. srcPos is the index from which copying starts. dest denotes the destination array destPos is the index from which the copied elements are placed in the destination array. length is the length of the subarray to be copied. -Using copyOf() method of Arrays class If we want to copy the first few elements of an array or a full copy of the array, you can use this method. Syntax: public static int[] copyOf(int[] original, int newLength) Parameters: Original array Length of the array to get copied. int b[] = Arrays.copyOf(a, 3); -Using copyOfRange() method of Arrays class This method copies the specified range of the specified array into a new array. Syntax: public static int[] copyOfRange (int[] original, int from, int to) Parameters: Original array from which a range is to be copied Initial index of the range to be copied Final index of the range to be copied, exclusive int b[] = Arrays.copyOfRange(a, 2, 6); */ import java.util.Arrays; class Arrays5{ public static void main(String[] args){ int a[] = {10,-20,40,10,50,90}; System.out.println(Arrays.toString(a)); } }