How to Extend an Array After Initialisation in Java? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In java, the arrays are immutable i.e. if the array is once assigned or instantiated the memory allocated for the array can't be decreased or increased. But there is one form of a solution in which we can extend the array. In this article, we will learn to increase the size of Array.Extending an Array after Initialization As we can't modify the array size after the declaration of the array, we can only extend it by initializing a new array and copying the values of the old array to the new array, and then we can assign new values to the array according to the size of the array declared.Below are the examples to show extending the array after initialization.Example 1: Java // Java program to demonstrate // extending an array import java.lang.*; class ExtendingArray { public static void main(String[] args) { String[] str = new String[] { "G", "E", "E" }; // allocating space for 5 strings // in the extended array String[] ext = new String[5]; ext[3] = "K"; ext[4] = "S"; // copying the array elements // to new extended array System.arraycopy(str, 0, ext, 0, str.length); for (String s : ext) { System.out.print(s); } } } OutputGEEKSExample 2: Java // Java program to demonstrate // extending an array import java.lang.*; class ExtendingArray { public static void extendedArray() { int[] arr = new int[] { 1, 2, 3, 4, 5, 6 }; // allocating space for 10 integers int[] arr2 = new int[10]; arr2[6] = 7; arr2[7] = 8; arr2[8] = 9; arr2[9] = 10; // copying old array to new array System.arraycopy(arr, 0, arr2, 0, arr.length); for (int str : arr2) System.out.print(str + " "); } public static void main(String[] args) { ExtendingArray arr = new ExtendingArray(); arr.extendedArray(); } } Output1 2 3 4 5 6 7 8 9 10 Comment More info K kadiummanisha Follow Improve Article Tags : Java Java Programs Java-Arrays Java-Array-Programs Explore Java BasicsIntroduction to Java4 min readJava Programming Basics9 min readJava Methods7 min readAccess Modifiers in Java6 min readArrays in Java9 min readJava Strings8 min readRegular Expressions in Java7 min readOOP & InterfacesClasses and Objects in Java10 min readAccess Modifiers in Java6 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface11 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java6 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling8 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking15+ min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples8 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz | Level Up Your Java Skills1 min readTop 50 Java Project Ideas For Beginners and Advanced [Update 2025]15+ min read Like