Hashtable in Java

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chandu

    Hashtable in Java

    Is there a way to optimize the use of Hashtable in java in terms
    of Memory and lookups

    what exactly are collisions in a hastable and how does it affect performance.

    Any help would be greatly appreciated

    Regards
  • Haakon Nilsen

    #2
    Re: Hashtable in Java

    Chandu wrote:
    [color=blue]
    > Is there a way to optimize the use of Hashtable in java in terms
    > of Memory[/color]

    Upon creation of a Hashtable, you often have some idea of the number of
    Objects that will immediately be put into it, so you can set the initial
    capacity to something that suits you. You can also set the load factor,
    but the default one should be just fine for most common uses.
    [color=blue]
    > and lookups[/color]

    Easy, don't look up more than you need to. If you need to use a value from
    the Hashtable several times in the same block (method or whatever), make a
    reference to it and use that instead of looking up more than once.
    [color=blue]
    > what exactly are collisions in a hastable and how does it affect
    > performance.[/color]

    <URL:http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html>

    Comment

    Working...