ArrayList and Hashtable growing size.
ArrayList has default initial capacity as 10 and
Hashtable has 11 with load factor 0.75
How much size ArrayList increses when a single element adds ?
is this double of current capacity or what ?
Same with Hashtable how much it grows when it reaches its load factor ?
Anybody can pls tell me.
# 1
I believe for array lists specifically, they double in capacity each time new elements are needed. So, choosing the proper initial size can have an impact on performance. (Small, but it exists). Not sure about HashMap. You can always look at the source code for the put() method. :^)
- Saish
# 2
> How much size ArrayList increses when a single
> element adds ?
'The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.'
> Same with Hashtable how much it grows when it reaches
> its load factor ?
It doesn't grow when it reaches its load factor. It grows when adding to it would make it exceed its load factor. How much it grows by isn't specified.
ejpa at 2007-7-8 23:52:43 >
