HashMap with Looping

We can iterate hashmap using enhanced for loop with keyset() method or by using enhanced for loop with EntrySet() method or by using iterator Case 1 : Enhanced for loop with keyset() Example import java.util.*; public class HashMapEnhancedForLoopExample { public static void main(String args[]) {   HashMap<Integer, String> hashMap = new HashMap<Integer, String>();     […]

Share this article on

Retrieve HashMap elements

We know that HashMap is a key-value pair based data structure. Sometimes, we need to retrieve all the keys of HashMap Sometimes we need to retrieve value for the specified key from the HashMap Sometimes we need to retrieve all the values from a HashMap Let’s see how we can achieve all these retrievals Case1: […]

Share this article on
< Previous Next >