Skip to content

Tag Archives: Java-HashMap

In hashing there is a hash function that maps keys to some values. But these hashing function may lead to collision that is two or… Read More
Given Inorder and Postorder traversals of a binary tree, print Preorder traversal. Example: Input: Postorder traversal post[] = {4, 5, 2, 6, 3, 1} Inorder traversal… Read More
HashMap is a part of the java collections framework. It internally uses hashing technique. This post contains different ways of traversing through a HashMap, which… Read More
HashMap is a part of java.util package.HashMap extends an abstract class AbstractMap which also provides an incomplete implementation of Map interface. It stores the data… Read More
Given a string, the task is to write a program in Java which prints the number of occurrences of each character in a string. Examples:… Read More
Given an array of N integers, the task is to find a non-empty subset such that the sum of elements of the subset is divisible… Read More
Given a very large number, print all the 3 digit repeating numbers with their frequency. If a 3 digit number appears more then once, print… Read More
Given marks scored out of 100 by a student in subjects where name of the subject is key and marks scored is the value. Our… Read More
The java.util.HashMap.containsKey() method is used to check whether a particular key is being mapped into the HashMap or not. It takes the key element as… Read More
The java.util.HashMap.clone() method is used to return a shallow copy of the mentioned hash map. It just creates a copy of the map. Syntax: Hash_Map.clone()… Read More
The java.util.HashMap.containsValue() method is used to check whether a particular value is being mapped by a single or more than one key in the HashMap.… Read More
The java.util.HashMap.isEmpty() method of HashMap class is used to check for the emptiness of the map. The method returns True if no key-value pair or… Read More
The java.util.HashMap.entrySet() method in Java is used to create a set out of the same elements contained in the hash map. It basically returns a… Read More
The java.util.HashMap.get() method of HashMap class is used to retrieve or fetch the value mapped by a particular key mentioned in the parameter. It returns… Read More
The java.util.HashMap.keySet() method in Java is used to create a set out of the key elements contained in the hash map. It basically returns a… Read More