What is the difference between Map and HashMap in java

0 votes
Can you please explain the difference between map and hashmap?

How they are different from each other?
May 31, 2019 in Java by sanhati
29,045 views

2 answers to this question.

0 votes

Hi Sanhati,

I understand your doubt regarding map and hash map.

Please check out my answer, I hope it will clear your doubts.

Hash map: 

  • It is the implementation of map interface.
  • It can contain null values and keys.
  • It doesn't maintain input order.

Map: 

  • It is an interface
  • Map has two implementation
  1. Tree Map
  2. Hash Map
  • Tree Map maintains the input order .
  • It will not allow any null values.
  • Duplicate keys are not allowed in the map
answered May 31, 2019 by sampriti
• 1,120 points
0 votes

The basic difference is : Map is an interface, i.e. an abstract "thing" that defines how something can be used. HashMap is an implementation of that interface.

If you need to know more about Java, then join our Java training class now.

answered Aug 28, 2019 by Sirajul
• 59,230 points

Related Questions In Java

0 votes
2 answers

What is the difference between Set and List in java?

List is an ordered sequence of elements. ...READ MORE

answered Apr 26, 2018 in Java by Akrati
• 3,190 points
62,763 views
0 votes
2 answers

What is the difference between getAttribute() and getParameter() in java?

getParameter() returns http request parameters. Those passed from ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
21,506 views
0 votes
2 answers

What is the difference between Type List and type ArrayList in Java

By List, you actually tell, that your object ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
2,266 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

answered Jul 26, 2018 in Java by Mrunal
• 680 points
1,675 views
+1 vote
1 answer

Are arrays equivalent to objects in Java ?

Yes; the Java Language Specification writes: In the Java ...READ MORE

answered May 10, 2018 in Java by Rishabh
• 3,620 points
1,035 views
+1 vote
1 answer

Remove objects from an array in Java?

We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE

answered Jun 26, 2018 in Java by scarlett
• 1,290 points
981 views
+1 vote
1 answer

Performance difference of if/else vs switch statement in Java

The thing you are worried about is ...READ MORE

answered Jul 26, 2018 in Java by geek.erkami
• 2,680 points
3,376 views
0 votes
2 answers

How to iterate in a HashMap in Java?

Iterating using Iterator. Using Generics: Map<Integer, Integer> map = ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
759 views
+2 votes
2 answers

Can you give me the proper difference between java.util.Date vs java.sql.Date ?

As per Javadoc java.sql.Date is a thin wrapper around millisecond ...READ MORE

answered Aug 2, 2019 in Java by sampriti
• 1,120 points
14,766 views
0 votes
2 answers

Please explain me the difference between scanner and the buffer reader?

As per your question for reading a ...READ MORE

answered Aug 27, 2019 in Java by Sirajul
• 59,230 points
3,434 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