values(): This method is available in java.util.WeakHashMap class in Java.
Syntax:
Collection<V> java.util.WeakHashMap.values()
This method returns a Collection view of the values contained in this map.
Note: The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.
Parameters: NA
Returns: a collection view of the values contained in this map.
Exceptions: NA
Approach
Java
import java.util.WeakHashMap;public class WeakHashMapvalues {public static void main(String[] args) {WeakHashMap<String, String> weakHashMap =new WeakHashMap<String, String>();weakHashMap.put("Java", "Program");weakHashMap.put("Hello", "World");System.out.println(weakHashMap.values());}}
Output:
[World, Program]
No comments:
Post a Comment