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
79 views

1 answer 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

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 3 days ago in Java by Sirajul
• 16,640 points
85 views
0 votes
1 answer

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

getParameter() - getParameter will return the value of ...READ MORE

answered Jun 29, 2018 in Java by Perry
• 17,010 points
447 views
0 votes
1 answer

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

Always TypeList is preferred over ArrayList. The ...READ MORE

answered Jul 9, 2018 in Java by Akrati
• 960 points
59 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
175 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
50 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
42 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,320 points
339 views
0 votes
1 answer

How to iterate in a HashMap in Java?

You can use for but in a ...READ MORE

answered Dec 4, 2018 in Java by Priyaj
• 56,200 points
42 views
0 votes
1 answer

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 in Java by Sampriti
• 1,100 points
15 views
0 votes
1 answer

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

BufferedReader is synchronous while Scanner is not.  BufferedReader ...READ MORE

answered Aug 2 in Java by Sampriti
• 1,100 points
19 views