Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HashMap Vs HashTable

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody tell me what is the difference between HashMap and hashTable and which one is more better than other and why.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HashMap & Hashtable both use hashing mechanism and store the entries as key value pairs.The difference between them is hashmap can store one null key & multiple null values,but hashtable doesn't allow anything(either a key or value) which is null.One more difference is hashtable is synchronized where as hashmap is not.Deciding the better one depends on ur design.

Regards,
Priya.
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jothi,

Can u please explain whats do u mean by "HashMap can hold one null key and multiple null values" ??
Whats the advantage of synchronised HashTable? When can v use it?

Can any one explain this pls...
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since Hashtable is synchronized it can be used safely in a multithreaded program guaranteeing exclusivity of access to a thread that holds its lock. HashMap does not have this functionality.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ja,

You are allowed only one null key in a HashMap whilst your are not allowed to use null in a HashTable as a key or value.

Hope this helps.

An
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic