A Vector is backed by an array. Since the dimension of an array is of type int, the capacity of a Vector (and thus its size too, since size <= capacity) is be at most Integer.MAX_VALUE.
If a Vector v already has the maximum size, then attempting to
addElement() will cause the following:
- The new size-to-be will be considered to be Integer.MAX_VALUE + 1, i.e. Integer.MIN_VALUE
- This being negative, hence smaller than the current capacity
will result in a request to ensure capacity not to be made
- An attempt to add the element will still be made (to position Integer.MIN_VALUE in the array). Integer.MIN_VALUE being negative, this will result in an ArrayIndexOutOfBoundsException.
Hope this helps,
Panagiotis.
[This message has been edited by Panagiotis Varlagas (edited January 10, 2001).]