Re: ArrayList.ensureCapacity should expand the default capacity empty array

2018-07-09 Thread Martin Buchholz
Thanks Alex, I filed https://bugs.openjdk.java.net/browse/JDK-8206945 I've had similar thoughts for years, but none have ended up in the actual code. I haven't seem the approach you used in your reallocate. On Thu, Jul 5, 2018 at 10:04 AM, Alex Foster wrote: > Hi, > > > I think that ensureCapaci

ArrayList.ensureCapacity should expand the default capacity empty array

2018-07-09 Thread Alex Foster
Hi, I think that ensureCapacity should actually ensure the capacity by expanding the default capacity empty array, otherwise you could end up with a situation like this: List> ls = getLists();// Large list of ArrayLists ls.forEach(l -> l.ensureCapacity(10)); //later...