This discussion is archived
6 Replies Latest reply: Mar 29, 2007 1:26 AM by 807606 RSS

HashTable size

807606 Newbie
Currently Being Moderated
What is the default capacity of a Hashtable.Is it possible to set the size of a hashtable.If so what method can i use
  • 1. Re: HashTable size
    gimbal2 Guru
    Currently Being Moderated
    Just look the class up in the API docs and all your questions are answered.

    http://java.sun.com/javase/6/docs/api/java/util/Hashtable.html

    (look at the constructors)
  • 2. Re: HashTable size
    807606 Newbie
    Currently Being Moderated
    I saw the API docs.It said the capacity is 11.What do you mean by 11.Is it the number of elements or is it in terms of Buckets.
  • 3. Re: HashTable size
    807606 Newbie
    Currently Being Moderated
    I saw the API docs.It said the capacity is 11.What do
    you mean by 11.Is it the number of elements or is it
    in terms of Buckets.
    How could a Hashtable contain entries without explicitely adding them ?

    Let's quote the API documentation :

    - The capacity is the number of buckets in the hash table, and the initial capacity is simply the capacity at the time the hash table is created.

    - public Hashtable() constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75).
  • 4. Re: HashTable size
    807606 Newbie
    Currently Being Moderated
    Thank you very much for the explanation.What do you mean by load factor
  • 5. Re: HashTable size
    791266 Explorer
    Currently Being Moderated
    Thank you very much for the explanation.What do you
    mean by load factor
    From the documentation:
    The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased.

    (You should really read it before you ask)
  • 6. Re: HashTable size
    807606 Newbie
    Currently Being Moderated
    Thank you very much for the explanation.What do you
    mean by load factor
    Would you mind reading the documentation (provided in the first reply) before asking ?