What is the difference between Map and HashMap in java

599    Asked by debbieJha in Salesforce , Asked on Apr 23, 2021

Can you please explain the difference between map and hashmap?


How they are different from each other?

Answered by Elizabeth Clark

 Here we have map vs hashmap java

The map is an interface and has two implementation

Tree Map

Hash Map

Hash map:

It is the implementation of map interface.

It can contain null values and keys.

It doesn't maintain input order.

The map is an interface and has two implementation

TreeMap

Tree Map maintains the input order .

It will not allow any null values.

Duplicate keys are not allowed in the map



Your Answer

Interviews

Parent Categories