Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
package com.tutorialspoint;
import java.util.Arrays;
public class ArrayDemo {
public static void main(String[] args) {
// intializing an array arr1
long[] arr1 = new long[] {15, 10, 45};
// printing the array
System.out.println("Printing 1st array:");
for (int i = 0; i < arr1.length; i++){
System.out.print(arr1[i]+" ");
}
System.out.println("");
// copying array arr1 to arr2 with newlength as 5
long[] arr2 = Arrays.copyOf(arr1, 16);
// printing the array arr2
System.out.println("Printing new array:");
for (int i = 0; i < arr2.length; i++) {
System.out.print(arr2[i]+" ");
}
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more