Java Map interface

In this tutorial we will discuss various implementations of Java Map interface. Java Map is one of the most commonly used datatypes when you want to store items by key.


HashMap


HashMap should be only used when the objects we store as KEYS have implemented the method hashCode in such way that it give unique key for a given object.

 @Override public int hashCode() {


Let's say we have an object USCitizen

name,
socialSecurityNumber


Map myMap = new HashMap();

No comments:

Post a Comment