[all packages] [java.util.Map] [class hierarchy] [index]

public interface java.util.Map.Entry<A, B>

This class is an inner class of java.util.Map<A, B>.
(source file: Map.java)
java.lang.Object
   |
   +----java.util.Map.Entry<A, B>

The pure class interface.
public interface Entry<A, B>
A Map entry (key-value pair). The Map.entries method returns a Collection-view of the Map, whose elements are of this class. The only way to obtain a reference to a Map.Entry is from the iterator of this Collection-view. These Map.Entry objects are valid only for the duration of the iteration; more formally, the behavior of a Map.Entry is undefined if the backing Map has been modified after the Entry was returned by the Iterator, except through the Iterator's own remove operation, or through the setValue operation of Map.Entries returned by the Iterator.

See also:
entries()

Methods

O equals(Object)
Compares the specified Object with this Entry for equality. Returns true if the given
O getKey()
Returns the key corresponding to this Entry.
O getValue()
Returns the value corresponding to this Entry
O hashCode()
Returns the hash code value for this Map.Entry
O setValue(B)
Replaces the value corresponding to this Entry with the specified value (optional

Methods

O getKey
public abstract A getKey();
Returns the key corresponding to this Entry.

O getValue

public abstract B getValue();
Returns the value corresponding to this Entry. If the mapping has been removed from the backing Map (by the Iterator's remove operation), the results of this call are undefined.

O setValue

public abstract B setValue(B value);
Replaces the value corresponding to this Entry with the specified value (optional operation). (Writes through to the Map.) The behavior of this call is undefined if the mapping has already been removed from the Map (by the Iterator's remove operation).

Parameters:
New - value to be stored in this Entry.
Returns:
old value corresponding to the Entry.
Throws:
UnsupportedOperationException -put operation is not supported by the backing Map.
ClassCastException -class of the specified value prevents it from being stored in the backing Map.
IllegalArgumentException -some aspect of this value prevents it from being stored in the backing Map.
NullPointerException -the backing Map does not permit null values, and the specified value is null.

O equals

public abstract boolean equals(Object o);
Compares the specified Object with this Entry for equality. Returns true if the given object is also a Map.Entry and the two Entries represent the same mapping. More formally, two Entries e1 and e2 represent the same mapping if (e1.getKey()==null ? e2.getKey()==null : e1.getKey().equals(e2.getKey())) && (e1.getValue()==null ? e2.getValue()==null : e1.getValue().equals(e2.getValue())) . This ensures that the equals method works properly across different implementations of the Map.Entry interface.

Parameters:
o - Object to be compared for equality with this Map.Entry.
Returns:
true if the specified Object is equal to this Map.Entry.
Overrides:
equals in class Object

O hashCode

public abstract int hashCode();
Returns the hash code value for this Map.Entry. The hash code of a Map.Entry e is defined to be: (e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null ? 0 : e.getValue().hashCode()) This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.

Overrides:
hashCode in class Object
See also:
hashCode(), equals(Object), equals(Object)


[all packages] [java.util.Map] [class hierarchy] [index]
java.util.Map.Entry.html