Flexibility of array size | SoloLearn: Learn to code for FREE!


Flexibility of array size

Can we dynamically increase our array size in Java?

11/19/2019 12:34:50 PM

Raj Shekhar

4 Answers

New Answer


Array are having fixed size but if you want an list with flexible size than there is a option. Like arrays only there is collections which are similar to array but not having fixed size. For example ArrayList, HashMap etc


Arrays are not dynamic that's why Linked lists come into picture. If you want to a larger array then just like Avinesh said copy the elements in larger array


Just like any other language if your entries go beyond the array size limit, you have to declare a new array with larger size and copy the elements of the previous array. But you can use an Array list in Java without doing the above. The size extension is internally handled.


No, increase/decrease of array is not possible once the size of array is fixed..Instead of array...you can use ArrayList which allows you to make changes in size.Based on the requirement,you can choose arrayList or LinkedList. For a better understanding, go through the link provided: https://www.sololearn.com/learn/Java/2179/