get(Object): This method is available in java.util.LinkedHashMap class of Java.
Syntax:
V java.util.LinkedHashMap.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.LinkedHashMap;public class LinkedHashMapget {public static void main(String args[]) {LinkedHashMap<String, Integer> linkedHashMap =new LinkedHashMap<String, Integer>();linkedHashMap.put("Java", 1);linkedHashMap.put("Hello", 2);Object key = "Java";System.out.println(linkedHashMap.get(key));}}
Output:
1
No comments:
Post a Comment