# Pair

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/Pair.java+class:androidx.core.util.Pair) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
class Pair<F, S>
```

<br />

*** ** * ** ***

Container to ease passing around a tuple of two objects. This object provides a sensible implementation of equals(), returning true if equals() is true on each of the contained objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#Pair(F,S)(first: F!, second: S!)` Constructor for a Pair. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/core/util/Pair<A!, B!>` | `<A, B> https://developer.android.com/reference/kotlin/androidx/core/util/Pair#create(A,B)(a: A!, b: B!)` Convenience method for creating an appropriately typed pair. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Checks the two objects for equality by delegating to their respective `https://developer.android.com/reference/java/lang/Object.html#equals(java.lang.Object)` methods. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#hashCode()()` Compute a hash code using the hash codes of the underlying objects |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#toString()()` |

| ### Public properties |
|---|---|
| `F!` | `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#first()` |
| `S!` | `https://developer.android.com/reference/kotlin/androidx/core/util/Pair#second()` |

| ### Extension functions |
|---|---|
| `inline operator F` | `<F : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, S : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/core/util/Pair<F, S>.https://developer.android.com/reference/kotlin/androidx/core/util/Pair#(androidx.core.util.Pair).component1()()` Returns the first component of the pair. |
| `inline operator S` | `<F : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, S : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/core/util/Pair<F, S>.https://developer.android.com/reference/kotlin/androidx/core/util/Pair#(androidx.core.util.Pair).component2()()` Returns the second component of the pair. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<F, S>` | `<F : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, S : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/core/util/Pair<F, S>.https://developer.android.com/reference/kotlin/androidx/core/util/Pair#(androidx.core.util.Pair).toKotlinPair()()` Returns this `https://developer.android.com/reference/kotlin/androidx/core/util/Pair` as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html`. |

## Public constructors

### Pair

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
Pair(first: F!, second: S!)
```

Constructor for a Pair.

| Parameters |
|---|---|
| `first: F!` | the first object in the Pair |
| `second: S!` | the second object in the pair |

## Public functions

### create

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
java-static fun <A, B> create(a: A!, b: B!): Pair<A!, B!>
```

Convenience method for creating an appropriately typed pair.

| Parameters |
|---|---|
| `a: A!` | the first object in the Pair |
| `b: B!` | the second object in the pair |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/core/util/Pair<A!, B!>` | a Pair that is templatized with the types of a and b |

### equals

```
fun equals(o: Any!): Boolean
```

Checks the two objects for equality by delegating to their respective `https://developer.android.com/reference/java/lang/Object.html#equals(java.lang.Object)` methods.

| Parameters |
|---|---|
| `o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | the `https://developer.android.com/reference/kotlin/androidx/core/util/Pair` to which this one is to be checked for equality |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if the underlying objects of the Pair are both considered equal |

### hashCode

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

Compute a hash code using the hash codes of the underlying objects

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | a hashcode of the Pair |

### toString

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

## Public properties

### first

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
val first: F!
```

### second

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
val second: S!
```

## Extension functions

### Pair.component1

Artifact: [androidx.core:core-ktx](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/Pair.kt+function:component1)

```
inline operator fun <F : Any?, S : Any?> Pair<F, S>.component1(): F
```

Returns the first component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

```kotlin
val (first, second) = myPair
```

### Pair.component2

Artifact: [androidx.core:core-ktx](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/Pair.kt+function:component2)

```
inline operator fun <F : Any?, S : Any?> Pair<F, S>.component2(): S
```

Returns the second component of the pair.

This method allows to use destructuring declarations when working with pairs, for example:

```kotlin
val (first, second) = myPair
```

### Pair.toKotlinPair

Artifact: [androidx.core:core-ktx](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/util/Pair.kt+function:toKotlinPair)

```
inline fun <F : Any?, S : Any?> Pair<F, S>.toKotlinPair(): Pair<F, S>
```

Returns this `https://developer.android.com/reference/kotlin/androidx/core/util/Pair` as a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html`.