+ 5
Flexibility of array size
Can we dynamically increase our array size in Java?
4 Respuestas
+ 5
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
+ 4
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
+ 2
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.
+ 1
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/