The ArrayList is an abstraction for an automatically growable List of elements. You rarely need to know its capacity. Consider Effective Java 2nd Edition, Item 52: Refer to objects by their interfaces. As much as practical, you should not even care if it's an ArrayList or a LinkedList; it's just a List.
That said, these methods may be of interest to you:
- ArrayList(int initialCapacity)
- Constructs an empty list with the specified initial capacity.
- void ensureCapacity(int minCapacity)
- Increases the capacity of this
ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
- void trimToSize()
- Trims the capacity of this
ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.