HashMap
hashMap.put("Matched", 1000L) ;
System.out.println("Map value" + hashMap.get("Unmatched")) ;
Output: null.
get
public V get(Object key)
- Returns the value to which the specified key is mapped, or
null
if this map contains no mapping for the key.More formally, if this map contains a mapping from a keyk
to a valuev
such that(key==null ? k==null : key.equals(k))
, then this method returnsv
; otherwise it returnsnull
. (There can be at most one such mapping.)
A return value ofnull
does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull
. ThecontainsKey
operation may be used to distinguish these two cases.
-
- Parameters:
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 - See Also:
put(Object, Object)
No comments:
Post a Comment