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

Java Array Resize

I'm trying to figure out how to resize an underlying array after removing elements in an ArrayList. So that after removing an element, the number of elements in the array is less than or equal to 25% of the array’s length. The underlying array should be shrunk to half its current length.

15th Sep 2020, 3:24 PM
GG128
1 Answer
+ 1
Try int arr[] = Arrays.copyOfRange(source, start, count) ; Edit : Array and ArrayList are different..
15th Sep 2020, 4:39 PM
Jayakrishna 🇮🇳