| 1 | <h2>Full example</h2> |
| 2 | <pre><code class="language-java">/** |
| 3 | * Returns the value to which the specified key is mapped, |
| 4 | * or {@code null} if this map contains no mapping for the key. |
| 5 | * |
| 6 | * <p>More formally, if this map contains a mapping from a key |
| 7 | * {@code k} to a value {@code v} such that {@code (key==null ? k==null : |
| 8 | * key.equals(k))}, then this method returns {@code v}; otherwise |
| 9 | * it returns {@code null}. (There can be at most one such mapping.) |
| 10 | * |
| 11 | * <p>If this map permits null values, then a return value of |
| 12 | * {@code null} does not <i>necessarily</i> indicate that the map |
| 13 | * contains no mapping for the key; it's also possible that the map |
| 14 | * explicitly maps the key to {@code null}. The {@link #containsKey |
| 15 | * containsKey} operation may be used to distinguish these two cases. |
| 16 | * |
| 17 | * @param key the key whose associated value is to be returned |
| 18 | * @return the value to which the specified key is mapped, or |
| 19 | * {@code null} if this map contains no mapping for the key |
| 20 | * @throws ClassCastException if the key is of an inappropriate type for |
| 21 | * this map |
| 22 | * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>) |
| 23 | * @throws NullPointerException if the specified key is null and this map |
| 24 | * does not permit null keys |
| 25 | * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>) |
| 26 | */ |
| 27 | V get(Object key); |
| 28 | |
| 29 | // Source: Java 1.8, Map#get(Object)</code></pre> |