using if loop to find key in hasmap and printing the value of that key code example
Example 1: print map in java
Map<String, Integer> map = new HashMap<>();
map.put("a", 1);
map.put("b", 2);
System.out.println(Arrays.asList(map)); // method 1
System.out.println(Collections.singletonList(map)); // method 2
Example 2: print only values in map
System.out.println(Arrays.toString(map.entrySet().toArray()));