HashMaps

HashMap is a collection that is based on a map class. Utilizes key and value pairs and is writing like this HashMap<key(that you want),Value>.

Image result for hashmaps

Don’t forget to import java.util.HashMap; So you can work with HashMaps

  • HashMap doesn’t allow duplicate keys but allows duplicate values. That means A single key can’t contain more than 1 value but more than 1 key can contain a single value.
  • This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time. It is roughly similar to HashTable but is unsynchronized.

How do we put our keys , and values in a hashMap ?

Let’s look at some very useful methods that it contains . ( all code will eb available at the bottom of the page with a link to the program in my Github)

citation : https://www.geeksforgeeks.org/java-util-hashmap-in-java/

Github : https://github.com/ValorWind1/eclipseJava/tree/master/eclipse1.0/src/hashmaps

Leave a comment