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,170 points
2,733 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
1,293 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,120 points
186 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 14, 2019 in Java by anonymous
159 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,170 points
136 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,870 points
126 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
2,523 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,870 points
58 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 6, 2018 by Omkar 41,888 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,110 points
6,737 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,350 points
4,856 views