Results 1 to 5 of 5

Thread: hi

  1. #1
    nagesh_java is offline Member
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Thumbs up hi

    in java why use Hash table what is special for hashtable.
    Last edited by nagesh_java; 01-03-2009 at 06:43 AM. Reason: change my msg

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    Gudradain is offline Member
    Join Date
    Nov 2008
    Posts
    44
    Rep Power
    0

    Default

    Hashtables are a type data structure. It use a key (Object) from which you get an integer using an hashCode. Using this integer you can access the cell in the array in which the element your are searching for is located (the one associated with the key).

    Another example of data structure is a list. The advantage of an hashTable over a list is that with an hashTable you find an specific element in your datastruture with an average worse case scenario of 1 ( O(1) ). With a list of n elements the worse case scenario is n (O (n) ).

    So the hashTable is a lot faster and your program will run faster.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Though I find that I rarely use HashTable and instead use the more recently created HashMap instead.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Thread starter edit his original post. It's not a good thing here, other members can confused on it.

    Personally I use HashTable most of the time. Reason is, as Gudradain says, referring the elements using hashcode is much useful to me in most of projects.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •