Array length | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Array length

Is there a way to make an array that just adds/subtracts from its length whenever a number is added/removed?

25th Oct 2016, 5:18 PM
Greg M
Greg M - avatar
1 Answer
+ 2
In java, there is ArrayList which does exactly what you want. They are created with initial size, but when this size is exceeded, the collection is automatically enlarged. When objects are removed, the ArrayList may shrink in size.
25th Oct 2016, 5:35 PM
Sumita Das
Sumita Das - avatar