Browsed by
Tag: for loop hashmap

Retrieving Hashmap value by comparing hashmap key

Retrieving Hashmap value by comparing hashmap key

Program: Hashmap.java package com.ngdeveloper.com; import java.util.HashMap; import java.util.Map.Entry; public class Hashmap { public static void main(String[] args) { String keyword="super"; HashMap<String, String> myMap = new HashMap<String, String>(); myMap.put("super", "java keyword"); myMap.put("array_merge", "php array function"); for (Entry<String, String> pair : myMap.entrySet()) { if(pair.getKey().equalsIgnoreCase(keyword)){ System.out.println(keyword+" is: " + pair.getValue()); } } } }   Output: super is: java keyword Thanks for reading this post…….!!! 711 total views, 5 views today

711 total views, 5 views today