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 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,200 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
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
• 57,640 points
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
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
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
+5 votes
3 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 29,566 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,510 points
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,510 points
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
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