All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Interface java.util.Map.Entry

public static interface Map.Entry
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.

Since:
JDK1.2
See Also:
entries

Method Index

 o equals(Object)
Compares the specified Object with this Entry for equality.
 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(Object)
Replaces the value corresponding to this Entry with the specified value (optional operation).

Methods

 o getKey
public abstract Object getKey()
Returns the key corresponding to this Entry.

 o getValue
public abstract Object 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 Object setValue(Object 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.
Throws: ClassCastException
class of the specified value prevents it from being stored in the backing Map.
Throws: IllegalArgumentException
some aspect of this value prevents it from being stored in the backing Map.
Throws: 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, equals

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature