Java tutorial
import java.util.Arrays; public class Main { public static void main(String[] args) { // intializing an array arr1 long[] arr1 = new long[] { 1L, 10L, 45L }; System.out.println(Arrays.toString(arr1)); // copying array arr1 to arr2 with newlength as 5 long[] arr2 = Arrays.copyOf(arr1, 5); arr2[3] = 12L; arr2[4] = 123456789L; System.out.println(Arrays.toString(arr2)); } }