values()
methodThe values()
method of the AbstractMap
class gets the Collections
view of the values stored in the map.
public Collection<V> values()
This method has no parameters.
This method returns a collection view of the values in the map.
import java.util.*;public class Main{public static void main(String[] args) {AbstractMap<String, String> abstractMap = new HashMap<>();abstractMap.put("hello-1", "Educative");abstractMap.put("hello-2", "edpresso");abstractMap.put("hello-3", "answers");System.out.println(abstractMap.values());}}
put()
method to add entries to the map.values()
method to obtain the values of the map. We then print these values.Free Resources