Results 1 to 6 of 6
  1. #1
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default what is the difference

    What is the difference between hashtable and hashmap

    one i found is hashtable is thread safe and hashmap is not

    any other differences?

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default

    Not really, I dug into this and found that a TreeMap will keep things sorted, for hashtable you get a lot of people telling you it is not in use anymore. They are worng ( wrong ) seems from what I read of hashmap it is not much different from hashtable except that you do not get as many people telling you it has been replaced.

    Threading issues do not matter unless you are writing a program that creates threads.
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

  3. #3
    ron87 is offline Member
    Join Date
    Mar 2009
    Posts
    52
    Rep Power
    0

    Default

    But i think they both does not allow null keys
    is it?

  4. #4
    arseny is offline Member
    Join Date
    Mar 2009
    Posts
    25
    Rep Power
    0

    Default

    yes it is. And there is one more HashMap works faster that Hashtable in a single tread environment (someone told).

  5. #5
    mrbharatmehta is offline Member
    Join Date
    Mar 2009
    Posts
    13
    Rep Power
    0

    Default

    Hashtable is the synchronized counterpart to HashMap. By this we mean that methods for Hashtable are synchronized.
    Another difference is that while HashMap lets you have null values as well as one null key, a Hashtable doesn't let you have anything that's null.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default

    Quote Originally Posted by Nicholas Jordan View Post
    Not really, I dug into this and found that a TreeMap will keep things sorted, for hashtable you get a lot of people telling you it is not in use anymore. They are worng ( wrong ) seems from what I read of hashmap it is not much different from hashtable except that you do not get as many people telling you it has been replaced.

    Threading issues do not matter unless you are writing a program that creates threads.
    Well, most places I've seen where this (and Vector) come up are that, outside of an environment where they are shared between threads, the newer (non-thread safe versions) should be used.

    Indeed, with the synchronised versions of the newer collections available (via the Collections class) it is arguable whether the older ones are required at all.

Similar Threads

  1. What is the difference between
    By arnab321 in forum New To Java
    Replies: 2
    Last Post: 01-19-2009, 04:49 AM
  2. what is the difference between jsp and jsf?
    By makpandian in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 12-31-2008, 05:55 PM
  3. difference
    By nishant in forum New To Java
    Replies: 2
    Last Post: 09-17-2008, 06:04 PM
  4. Difference between http and ftp
    By islamfunny in forum CLDC and MIDP
    Replies: 6
    Last Post: 08-14-2008, 07:12 AM
  5. Difference between ASP and JSP
    By barney in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:15 AM

Posting Permissions

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