# AbstractMap.SimpleImmutableEntry

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

# SimpleImmutableEntry

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

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

An unmodifiable Entry maintaining a key and a value. This class does not support the`setValue`method. Instances of this class are not associated with any map nor with any map's entry-set view.

## Summary

|                                                                                                                                                                                                  Public constructors                                                                                                                                                                                                  ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [SimpleImmutableEntry](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#SimpleImmutableEntry(kotlin.collections.MutableMap.MutableEntry))`(`entry:` `[MutableEntry](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. |
| [SimpleImmutableEntry](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry.K,%20java.util.AbstractMap.SimpleImmutableEntry.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) | [equals](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#equals(kotlin.Any))`(`other:` `[Any](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)         | [hashCode](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#hashCode())`()` Returns the hash code value for this map entry.                                                                                                          |
| openV                                                                                  | [setValue](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#setValue(java.util.AbstractMap.SimpleImmutableEntry.V))`(`newValue:` `V`)` Replaces the value corresponding to this entry with the specified value (optional operation). |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)   | [toString](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#toString())`()` Returns a String representation of this map entry.                                                                                                       |

|                                                                                                 Properties                                                                                                  ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| openK | [key](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#key:java.util.AbstractMap.SimpleImmutableEntry.K) Returns the key corresponding to this entry.       |
| openV | [value](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#value:java.util.AbstractMap.SimpleImmutableEntry.V) Returns the value corresponding to this entry. |

## Public constructors

### SimpleImmutableEntry

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

```
SimpleImmutableEntry(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)\<outK,outV\>:the entry to copy |

### SimpleImmutableEntry

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

```
SimpleImmutableEntry(
    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                                                                    ||
|------------------------------------------------------------------------------------|----------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the specified object is equal to this map entry |

**See Also**

- [#hashCode](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#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[Object.hashCode](https://developer.android.com/reference/kotlin/java/lang/Object.html#hashCode()).

<br />

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

**See Also**

- [#equals](https://developer.android.com/reference/kotlin/java/util/AbstractMap.SimpleImmutableEntry#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 (optional operation). This implementation simply throws`UnsupportedOperationException`, as this class implements an unmodifiable map entry.

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

|        Return        ||
|---|-------------------|
| V | (Does not return) |

|                                                                            Exceptions                                                                             ||
|-------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException` | always                                                                                                                 |
| `java.lang.ClassCastException`            | if the class of the specified value prevents it from being stored in the backing map                                   |
| `java.lang.NullPointerException`          | if the backing map does not permit null values, and the specified value is null                                        |
| `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. |

### 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                                                            ||
|----------------------------------------------------------------------------------|-------------------------------------------|
| [String](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. |