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.

[328 byte] By [nitin.softplusa] at [2007-11-26 17:24:42]
# 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

Saisha at 2007-7-8 23:52:43 > top of Java-index,Core,Core APIs...
# 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 > top of Java-index,Core,Core APIs...
# 3
hmm. so sun did not tell specifically about the growth size.......I was egar to know about the growth.anyway thank ejp for your answer.
nitin.softplusa at 2007-7-8 23:52:43 > top of Java-index,Core,Core APIs...