6 Replies Latest reply on Mar 29, 2007 8:26 AM by 807606

    HashTable size

    807606
      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
          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
            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
              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
                Thank you very much for the explanation.What do you mean by load factor
                • 5. Re: HashTable size
                  791266
                  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
                    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 ?