get(Object): This method is available in java.util.IdentityHashMap class of Java.
Syntax:
V java.util.IdentityHashMap.get(Object key)
This method takes one argument. This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Parameters: One parameter is required for this method.
key: the key whose associated value is to be returned.
Returns: the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Exceptions: NA
Approach
Java
import java.util.IdentityHashMap;public class IdentityHashMapget {public static void main(String args[]) {IdentityHashMap<String, Integer> identityHashMap =new IdentityHashMap<String, Integer>();identityHashMap.put("Java", 1);identityHashMap.put("Hello", 2);Object key = "Java";System.out.println(identityHashMap.get(key));}}
Output:
1
No comments:
Post a Comment