public static class AbstractMap.SimpleEntry<K,V> extends Object implements Map.Entry<K,V>, Serializable
Constructor and Description |
---|
AbstractMap.SimpleEntry(K newKey,
V newValue)
Basic constructor initializes the fields.
|
AbstractMap.SimpleEntry(Map.Entry<? extends K,? extends V> entry) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Compares the specified object with this entry.
|
K |
getKey()
Get the key corresponding to this entry.
|
V |
getValue()
Get the value corresponding to this entry.
|
int |
hashCode()
Returns the hash code of the entry.
|
V |
setValue(V newVal)
Replaces the value with the specified object.
|
String |
toString()
This provides a string representation of the entry.
|
public AbstractMap.SimpleEntry(K newKey, V newValue)
newKey
- the keynewValue
- the valuepublic AbstractMap.SimpleEntry(Map.Entry<? extends K,? extends V> entry)
public boolean equals(Object o)
(o instanceof Map.Entry) && (getKey() == null ? ((HashMap) o).getKey() == null : getKey().equals(((HashMap) o).getKey())) && (getValue() == null ? ((HashMap) o).getValue() == null : getValue().equals(((HashMap) o).getValue()))
public V getValue()
public int hashCode()
(getKey() == null ? 0 : getKey().hashCode()) ^ (getValue() == null ? 0 : getValue().hashCode())
hashCode
in interface Map.Entry<K,V>
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)
public V setValue(V newVal)
setValue
in interface Map.Entry<K,V>
newVal
- the new value to storeNullPointerException
- if the map forbids null values.UnsupportedOperationException
- if the map doesn't support
put()
.ClassCastException
- if the value is of a type unsupported
by the map.IllegalArgumentException
- if something else about this
value prevents it being stored in the map.public String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)