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.
Tutorialspoint

Java Program to extend the size of an Integer array

public class Demo {
	public static void main(String[] args) {
		Integer[] arr = new Integer[] { 50, 100, 150, 200, 400, 500, 800, 1000};
		System.out.println("All the elements before extending the array...");
		for (Integer i:arr)
			System.out.println(i);
			Integer[] new_size = new Integer[15];
			new_size[8] = 2000;
			new_size[9] = 3000;
			new_size[10] = 4000;
			new_size[11] = 5000;
			new_size[12] = 6000;
			new_size[13] = 9000;
			new_size[14] = 10000;
			System.arraycopy(arr, 0, new_size, 0, arr.length);
			System.out.println("All the elements after extending the array...");
			for (Integer i: new_size)
				System.out.println(i);
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.