Java – HashMap

HashMap stores items pairs, key-value pairs. You can find it in other languages with other names such as hashtable, dictionary, associative array etc. HashMap is unordered but it is very fast. Every key is unique. The keys and values should not be primitive types. HashMap implements the Map interface and it is recommended to declare a HashMap object using the Map interface for future changes.

Java hashmap methods syntax example, <span>Java – HashMap</span>, KandZ
Java hashmap methods syntax example, <span>Java – HashMap</span>, KandZ

Common methods:

Please notice that HashMap is not a collection, so no iterator is provided. You can use the following methods to return a collection:

  • values() – Returns a Collection view of the values contained in this map.
  • keySet() – Returns a Set view of the keys contained in this map.

You can read more here.

Java hashmap methods syntax example, <span>Java – HashMap</span>, KandZ
Java hashmap methods syntax example, <span>Java – HashMap</span>, KandZ

THE END!!!

87500cookie-checkJava – HashMapJava – HashMap

Related posts

3 Thoughts to “Java – HashMap

Comments are closed.