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,484 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
63,360 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
22,551 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,567 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,909 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,326 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
1,185 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,739 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
1,021 views
+2 votes
2 answers

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

 java.sql.Date is a thin wrapper around millisecond value ...READ MORE

answered Aug 2, 2019 in Java by sampriti
• 1,120 points
15,454 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,790 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