How is hashmap different from hashtable

0 votes
I cannot differentiate between the two terminologies Hashmap and Hashtable.
Apr 16, 2018 in Java by Akrati
• 3,190 points
5,989 views

2 answers to this question.

0 votes


Here are few differences between HashMap and HashTable:

  • HashMap is non synchronized whereas HashTable is synchronized.
  • HashMap is fast whereas HashTable is slow
  • HashMap allows one null key and multiple null values whereas HashTable doesn't allow any null value or key.
  • HashMap inherits AbstractMap class whereas HashTable inherits Dictionary class.
  • HashMap is traversed by Iterator whereas HashTable is traversed by Enumerator and Iterator.

answered Apr 16, 2018 by anonymous
0 votes

HashMap and HashTable:

1) Hashtable and Hashmap implement the java.util.Map interface

2) Both Hashmap and Hashtable is the hash-based collection. and working on hashing. so these are similarity of HashMap and HashTable.

  • What is the difference between HashMap and HashTable?

1) The first difference is HashMap is not thread safe While HashTable is ThreadSafe
2) HashMap is performance wise better because it is not thread safe. while Hashtable performance wise is not better because it is thread safe. so multiple thread cannot access Hashtable at the same time.

answered Aug 1, 2018 by samarth295
• 2,220 points

Related Questions In Java

0 votes
1 answer

Is it possible to run a java program from command line on windows?How?

  Let's say your file is in C:\myprogram\ Run ...READ MORE

answered Apr 18, 2018 in Java by sophia
• 1,400 points
2,371 views
0 votes
1 answer

How is inheritance in C++ different than that in Java?

The purpose of inheritance is same for ...READ MORE

answered Feb 6, 2019 in Java by Priyaj
• 58,090 points
731 views
0 votes
1 answer

Can you explain what is the difference between hashtable and hashmap?

Hi, Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for ...READ MORE

answered Aug 15, 2019 in Java by anonymous
557 views
0 votes
1 answer

How to take input from users?

Scanner Class is used to take input ...READ MORE

answered Apr 17, 2018 in Java by Akrati
• 3,190 points
573 views
0 votes
1 answer

What are the differences between a HashMap and a Hashtable in Java?

There are several differences between HashMap and Hashtable in Java: Hashtable is synchronized, whereas HashMap is ...READ MORE

answered Dec 21, 2020 in Java by Gitika
• 65,910 points
826 views
0 votes
1 answer

Good Hash Function for Strings

Usually hashes wouldn't do sums, otherwise, stop and pots will have ...READ MORE

answered Jul 19, 2018 in Java by Akrati
• 960 points
3,441 views
0 votes
1 answer

Iterate through a HashMap.

Iterate through the entrySet() like so: public static void printMap(Map ...READ MORE

answered Dec 22, 2020 in Java by Gitika
• 65,910 points
512 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 79,470 views
0 votes
3 answers

Is it possible to take char input from scanner?

// Use a BufferedReader to read characters ...READ MORE

answered Sep 7, 2018 in Java by Daisy
• 8,120 points
8,539 views
0 votes
1 answer

How to build jars from IntelliJ properly?

How to build a jar with IntelliJ ...READ MORE

answered Oct 12, 2018 in Java by sharth
• 3,370 points
7,164 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP