Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.util

Interface Map.Entry

java.lang.Object
|
+--java.util.Map.Entry


public static interface Map.Entry

A map entry (key-value pair). The Map.entrySet() method returns a set view of these objects; there is no other valid way to come across them. These objects are only valid for the duration of an iteration; in other words, if you mess with one after modifying the map, you are asking for undefined behavior.

Since:Authors:See Also:

Method Summary

booleanequals(java.lang.Object o)

Compares the specified object with this entry.
java.lang.ObjectgetKey()

Get the key corresponding to this entry.
java.lang.ObjectgetValue()

Get the value corresponding to this entry.
inthashCode()

Returns the hash code of the entry.
java.lang.ObjectsetValue(java.lang.Object value)

Replaces the value with the specified object (optional operation).

Method Details

equals

public boolean equals(java.lang.Object o)

Compares the specified object with this entry. Returns true only if the object is a mapping of identical key and value. In other words, this must be:

(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()))

Parameters:

Returns:


getKey

public Object getKey()

Get the key corresponding to this entry.

Returns:


getValue

public Object getValue()

Get the value corresponding to this entry. If you already called Iterator.remove(), this is undefined.

Returns:


hashCode

public int hashCode()

Returns the hash code of the entry. This is defined as the exclusive-or of the hashcodes of the key and value (using 0 for null). In other words, this must be:

(getKey() == null ? 0 : getKey().hashCode())
^ (getValue() == null ? 0 : getValue().hashCode())

Returns:


setValue

public Object setValue(java.lang.Object value)

Replaces the value with the specified object (optional operation). This writes through to the map, and is undefined if you already called Iterator.remove().

Parameters:

Returns:

Throws: