Skip to content

Tag Archives: Java-HashMap

The getOrDefault(Object key, V defaultValue) method of Map interface, implemented by HashMap class is used to get the value mapped with specified key. If no… Read More
The forEach(BiConsumer) method of HashMap class perform the BiConsumer operation on each entry of hashmap until all entries have been processed or the action throws… Read More
The merge(Key, Value, BiFunctional) method of HashMap class is used to combine multiple mapped values for a key using the given mapping function. Bucket is… Read More
The putIfAbsent(K key, V value) method of HashMap class is used to map the specified key with the specified value, only if no such key… Read More
The replace(K key, V oldValue, V newValue) method of Map interface, implemented by HashMap class is used to replace the old value of the specified… Read More
The replace(K key, V value) method of Map interface, implemented by HashMap class is used to replace the value of the specified key only if… Read More
Given a string of lowercase English alphabets and an integer 0 < K <= 26. The task is to divide the string into two parts… Read More
Pre-requisite: Internal working of HashMap, HashMap If we wish to create a HashMap of our own class, we need to ensure that the hashcode() of… Read More
Write a function to check whether two given strings are an Anagram of each other or not. An anagram of a string is another string… Read More
Given a map, the task is to clone that map. Following are the 5 different ways to Clone a Map in Java. Example: {1=Geeks, 2=For,… Read More
Given an array arr[] having 4 integer digits only. The task is to return the maximum 24 hour time that can be formed using the… Read More
ArrayList is a part of collection framework and is present in java.util package. It provides us dynamic arrays in Java. Though, it may be slower… Read More
Given an array of distinct elements, the task is to find the total number of two element pairs from the array whose sum is a… Read More
Given an array of N integers, rearrange the array elements such that the next array element is greater than the previous element ( > ).… Read More
Given an array of N integers and a number M. The task is to find out the maximum number of unique integers among all possible… Read More