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 in Java by sanhati
372 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 by sampriti
• 1,100 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.
answered Aug 28 by Sirajul
• 31,980 points

Related Questions In Java

0 votes
2 answers

What is the difference between Set and List in java?

LIST SET Duplicates YES NO Order Ordered Depends on Implementation Positional Access YES NO List is an ordered sequence ...READ MORE

answered Aug 14 in Java by Sirajul
• 31,980 points
128 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 in Java by Sirajul
• 31,980 points
808 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 in Java by Sirajul
• 31,980 points
84 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 25, 2018 in Java by Mrunal
• 680 points
262 views
0 votes
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,540 points
69 views
0 votes
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,280 points
58 views
0 votes
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,640 points
482 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 in Java by Sirajul
• 31,980 points
53 views
0 votes
2 answers

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

The java.util.date class represents a particular moment in time, with ...READ MORE

answered Aug 27 in Java by Sirajul
• 31,980 points
90 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 in Java by Sirajul
• 31,980 points
69 views