In Java, is there any way to determine what initial capacity was used to create a Collection?
So when a collection was created like this:
List<Object> objectList = new ArrayList<Object>(5);
Is there any way to tell the objectList was created with an initial capacity of 5?
No, the ArrayList class at least does not keep track of the originalCapacity value passed in.
If you are worried about operations on the ArrayList requiring resizing of the internal array, you can always call
ArrayList.ensureCapacity(int).