Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# SimpleEntry

```
open class SimpleEntry<K : Any!, V : Any!> : MutableEntry<K, V>, Serializable
```

|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||
| ↳ | [java.util.AbstractMap.SimpleEntry](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#) |

An Entry maintaining a key and a value. The value may be changed using the `setValue` method. Instances of this class are not associated with any map nor with any map's entry-set view.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#SimpleEntry(kotlin.collections.MutableMap.MutableEntry)(entry: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/-mutable-entry/index.html<out K, out V>)` Creates an entry representing the same mapping as the specified entry. |
| `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#SimpleEntry(java.util.AbstractMap.SimpleEntry.K,%20java.util.AbstractMap.SimpleEntry.V)(key: K, value: V)` Creates an entry representing a mapping from the specified key to the specified value. |

| Public methods ||
|---|---|
| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#equals(kotlin.Any)(other: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html?)` Compares the specified object with this entry for equality. |
| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#hashCode()()` Returns the hash code value for this map entry. |
| open V | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#setValue(java.util.AbstractMap.SimpleEntry.V)(newValue: V)` Replaces the value corresponding to this entry with the specified value. |
| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#toString()()` Returns a String representation of this map entry. |

| Properties ||
|---|---|
| open K | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#key:java.util.AbstractMap.SimpleEntry.K` Returns the key corresponding to this entry. |
| open V | `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#value:java.util.AbstractMap.SimpleEntry.V` Returns the value corresponding to this entry. |

## Public constructors

### SimpleEntry

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
SimpleEntry(entry: MutableEntry<out K, out V>)
```

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

| Parameters ||
|---|---|
| `entry` | [MutableEntry](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/-mutable-entry/index.html)\<out K, out V\>: the entry to copy |

### SimpleEntry

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
SimpleEntry(
    key: K, 
    value: V)
```

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

| Parameters ||
|---|---|
| `key` | K: the key represented by this entry |
| `value` | V: the value represented by this entry |

## Public methods

### equals

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun equals(other: Any?): Boolean
```

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

```kotlin
(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 ||
|---|---|
| `obj` | the reference object with which to compare. |
| `o` | object to be compared for equality with this map entry |

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `true` if the specified object is equal to this map entry |

**See Also**

- `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#hashCode()`

### hashCode

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun hashCode(): Int
```

Returns the hash code value for this map entry. The hash code of a map entry `e` is defined to be:

```kotlin
(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://developer.android.com/reference/kotlin/java/lang/Object.html#hashCode()`.

<br />

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | the hash code value for this map entry |

**See Also**

- `https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleEntry#equals(kotlin.Any)`

### setValue

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun setValue(newValue: V): V
```

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

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

| Return ||
|---|---|
| `V` | the old value corresponding to the entry |

| Exceptions ||
|---|---|
| `java.lang.ClassCastException` | if the class of the specified value prevents it from being stored in the backing map |
| `java.lang.IllegalArgumentException` | if some property of this value prevents it from being stored in the backing map |
| `java.lang.IllegalStateException` | implementations may, but are not required to, throw this exception if the entry has been removed from the backing map. |
| `java.lang.NullPointerException` | if the backing map does not permit null values, and the specified value is null |
| `java.lang.UnsupportedOperationException` | if the `put` operation is not supported by the backing map |

### toString

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open fun toString(): String
```

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.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | a String representation of this map entry |

## Properties

### key

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open val key: K
```

Returns the key corresponding to this entry.

| Return ||
|---|---|
| `K` | the key corresponding to this entry |

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | implementations may, but are not required to, throw this exception if the entry has been removed from the backing map. |

### value

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
open val value: V
```

Returns the value corresponding to this entry.

| Return ||
|---|---|
| `V` | the value corresponding to this entry |

| Exceptions ||
|---|---|
| `java.lang.IllegalStateException` | implementations may, but are not required to, throw this exception if the entry has been removed from the backing map. |