The API documentation wrote:Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added to an ArrayList, its capacity grows automatically.
R. Grimes wrote:It seems to me that the API documentation is a bit ambiguous.
I would interpret that as growing (by 1) as you add objects to the list.
Is there really that much performance improvement by adding multiple elements on an add, rather than one at a time, as needed?
R. Grimes wrote: I can't believe the performance outweighs the potential unintended consequences when developers either fail to trim the trailing null elements or code to bypass them.
R. Grimes wrote:@Henry: Both. The size() method returns 38, the debugger shows the object as having an "elementCount" of 38.
Steve
straws are for suckers. tiny ads are for attractive people.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|