Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java

What is AbstractMap values() in Java?

Abhilash

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

The values()method

The values() method of the AbstractMap class gets the Collections view of the values stored in the map.

Syntax

public Collection<V> values()

Parameters

This method has no parameters.

Return value

This method returns a collection view of the values in the map.

Example

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());
}
}
The values() method

Explanation

  • Line 5: We define an abstract map. The abstract map has the implementation of the hash map.
  • Lines 6–8: We use the put() method to add entries to the map.
  • Line 9: We invoke the values() method to obtain the values of the map. We then print these values.

RELATED TAGS

java

CONTRIBUTOR

Abhilash
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring