import java.util.HashMap; import java.util.Map; public class MapValuesExample { public static void main(String[] args) { MapIn the above example, we have created a HashMap and added some key/value pairs to it. We have then used the values() method of the Map interface to get the values stored in the map and printed them to the console. The MapValuesExample class belongs to the Java core library and does not require any additional package or library to be imported.map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); // Getting the values from Map for (String value: map.values()) { System.out.println(value); } } }