Get HashMap keys in sorted order
As we discussed in what is hash map, the entries of the HashMap is not guaranteed to be in any specific order. Hashing algorithm is meant to store it in an efficient way and not in the order. However, at times you come across the situation where you have to list the keys in order.… Continue reading Get HashMap keys in sorted order
How to iterate through a HashMap
Looping through Hash Map is using an iterator. You can get an iterator of Key Set and loop through it. Provide the correct data type of the entries to make it nice and clean. Here is the example: Iterator<Entry<String,String>> itr= mapObj.entrySet().iterator();//give the right type for key and value here. while (itr.hasNext()) { Map.Entry<String,String> entry =… Continue reading How to iterate through a HashMap
HashMap Helpful Resources on the web
Some of the useful resources I found on web about Hashmap: Optimizing for Hash Functions: http://archive.oreilly.com/pub/a/onjava/2001/01/25/hash_functions.html Non blocking HashTable, well HashTable. Still you may be interested. http://www.azulsystems.com/blog/cliff/2007-03-26-non-blocking-hashtable The official docs: https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html Check this back later. I will add more resources.
How to Sort a HashMap
HashMap key set is not guaranteed to be in any order. However, you can easily sort a HashMap using TreeMap. TreeMap is a tree implementation of Map, that can take key-value pair. If you want to just order by the natural order, you can use the default constructor. If you want to set your own… Continue reading How to Sort a HashMap
What is a HashMap
HashMap is the data structure where you can store key-value pairs. There is no better place other than official java API to get more details about it. Wherever you can map two different things and wants to fetch one by providing another, HashMap could be used. If you see pictorial illustration, it will be easy… Continue reading What is a HashMap
7 Differences between HashMap and HashTable
Here are the differences between a HashMap and HashTable. HashMap is a newer introduction than HashTable HashMap is not thread safe, but HashTable is thread safe. HashMap is better in performance since it is not synchronized ( and thus not thread safe). It is up to the developer to analyze the situation and make it… Continue reading 7 Differences between HashMap and HashTable
How to use Java HashMap
This video will show basic code sample of how to use HashMap. This will cover the basics.
About
This site is all about Java HashMap. Whenever you want to keep a key and a value associated to that HashMap is the right data structure. The applications of HashMash and how it stores the data and retrieves it all I have tried to cover here. You will find articles, Illustrations and code samples here.… Continue reading About
Welcome
Welcome to the Java Hash Map. This site is dedicated for exploring the Java HashMap in depth. Keep visiting for in articles and code samples of Java HashMap