# AbstractMap.SimpleEntry

public static class **AbstractMap.SimpleEntry** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<K, V\> [Serializable](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/Serializable.html) An Entry maintaining a key and a value. The value may be
changed using the setValue method. This class
facilitates the process of building custom map
implementations. For example, it may be convenient to return
arrays of SimpleEntry instances in method
Map.entrySet().toArray.

### Public Constructor Summary

|---|---|
|   | [SimpleEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#SimpleEntry(K,%20V))(K key, V value) Creates an entry representing a mapping from the specified key to the specified value. |
|   | [SimpleEntry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#SimpleEntry(java.util.Map.Entry<?%20extends%20K,%20?%20extends%20V>))([Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<? extends K, ? extends V\> entry) Creates an entry representing the same mapping as the specified entry. |

### Public Method Summary

|---|---|
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this entry for equality. |
| K | [getKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#getKey())() Returns the key corresponding to this entry. |
| V | [getValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#getValue())() Returns the value corresponding to this entry. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#hashCode())() Returns the hash code value for this map entry. |
| V | [setValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#setValue(V))(V value) Replaces the value corresponding to this entry with the specified value. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#toString())() Returns a String representation of this map entry. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.util.Map.Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)

|---|---|
| static \<K, V\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<K, V\>\> | [comparingByKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#comparingByKey(java.util.Comparator<?%20super%20K>))([Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super K\> cmp) Returns a comparator that compares `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html` by key using the given `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html`. |
| static \<K extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super K\>, V\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<K, V\>\> | [comparingByKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#comparingByKey())() Returns a comparator that compares `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html` in natural order on key. |
| static \<K, V\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<K, V\>\> | [comparingByValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#comparingByValue(java.util.Comparator<?%20super%20V>))([Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<? super V\> cmp) Returns a comparator that compares `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html` by value using the given `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html`. |
| static \<K, V extends [Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)\<? super V\>\> [Comparator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Comparator.html)\<[Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<K, V\>\> | [comparingByValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#comparingByValue())() Returns a comparator that compares `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html` in natural order on value. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) o) Compares the specified object with this entry for equality. |
| abstract K | [getKey](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#getKey())() Returns the key corresponding to this entry. |
| abstract V | [getValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#getValue())() Returns the value corresponding to this entry. |
| abstract int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#hashCode())() Returns the hash code value for this map entry. |
| abstract V | [setValue](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html#setValue(V))(V value) Replaces the value corresponding to this entry with the specified value (optional operation). |

## Public Constructors

#### public
**SimpleEntry**
(K key, V value)

Creates an entry representing a mapping from the specified
key to the specified value.

##### Parameters

| key | the key represented by this entry |
| value | the value represented by this entry |
|---|---|

#### public
**SimpleEntry**
([Entry](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Map.Entry.html)\<? extends K, ? extends V\> entry)

Creates an entry representing the same mapping as the
specified entry.

##### Parameters

| entry | the entry to copy |
|---|---|

## Public Methods

#### public boolean
**equals**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) 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.

<br />

##### Parameters

| o | object to be compared for equality with this map entry |
|---|---|

##### Returns

- `true` if the specified object is equal to this map entry

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#hashCode()`

#### public K
**getKey**
()

Returns the key corresponding to this entry.

##### Returns

- the key corresponding to this entry

#### public V
**getValue**
()

Returns the value corresponding to this entry.

##### Returns

- the value corresponding to this entry

#### public 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 `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode()`.

<br />

##### Returns

- the hash code value for this map entry

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/AbstractMap.SimpleEntry.html#equals(java.lang.Object)`

#### public V
**setValue**
(V value)

Replaces the value corresponding to this entry with the specified
value.

##### Parameters

| value | new value to be stored in this entry |
|---|---|

##### Returns

- the old value corresponding to the entry

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Returns a String representation of this map entry. This
implementation returns the string representation of this
entry's key followed by the equals character ("=")
followed by the string representation of this entry's value.

##### Returns

- a String representation of this map entry