i think ArrayList is the right choice, but you can...
# stdlib
j
i think ArrayList is the right choice, but you can do less work than it will by allocating arrays in the same doubling fashion except instead of constantly copying into the new array use the last element as a pointer to the next array to form a linked list. once you're done, do a single pass of arraycopys to fill an exact-sized array. this will allocate less and copy less than ArrayList would even ignoring a final toArray call.
😮 2
🔥 2