# Pair

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1  
Summary:[Fields](https://developer.android.com/reference/android/support/v4/util/Pair#lfields)\|[Ctors](https://developer.android.com/reference/android/support/v4/util/Pair#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/util/Pair#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/util/Pair#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/util/Pair#)  

# Pair

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
Pair
`  
`

extends Object


``


`

|---|--------------------------------------|
| java.lang.Object                        ||
| ↳ | android.support.v4.util.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

|                                                   ### Fields                                                    ||
|-------------------|----------------------------------------------------------------------------------------------|
| ` public final F` | [first](https://developer.android.com/reference/android/support/v4/util/Pair#first) <br />   |
| ` public final S` | [second](https://developer.android.com/reference/android/support/v4/util/Pair#second) <br /> |

|                                                           ### Public constructors                                                           ||
|------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Pair](https://developer.android.com/reference/android/support/v4/util/Pair#Pair(F, S))`(F first, S second) ` Constructor for a Pair. |

|                                                                                                                                                                                               ### Public methods                                                                                                                                                                                                ||
|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static <A, B> `[Pair](https://developer.android.com/reference/android/support/v4/util/Pair)`<A, B>` | ` `[create](https://developer.android.com/reference/android/support/v4/util/Pair#create(A, B))`(A a, B b) ` Convenience method for creating an appropriately typed pair.                                                                                                                                 |
| ` boolean`                                                                                            | ` `[equals](https://developer.android.com/reference/android/support/v4/util/Pair#equals(java.lang.Object))`(Object o) ` Checks the two objects for equality by delegating to their respective[equals(Object)](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))methods. |
| ` int`                                                                                                | ` `[hashCode](https://developer.android.com/reference/android/support/v4/util/Pair#hashCode())`() ` Compute a hash code using the hash codes of the underlying objects                                                                                                                                   |
| ` String`                                                                                             | ` `[toString](https://developer.android.com/reference/android/support/v4/util/Pair#toString())`() `                                                                                                                                                                                                      |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/util/Pair#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Fields

### first

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
F first
```

<br />

<br />

### second

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
S second
```

<br />

<br />

## Public constructors

### Pair

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Constructor for a Pair.

<br />

|                     Parameters                      ||
|----------|-------------------------------------------|
| `first`  | `F`: the first object in the Pair <br />  |
| `second` | `S`: the second object in the pair <br /> |

## Public methods

### create

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
Pair<A, B> create (A a, 
                B b)
```

Convenience method for creating an appropriately typed pair.

<br />

|                   Parameters                   ||
|-----|-------------------------------------------|
| `a` | `A`: the first object in the Pair <br />  |
| `b` | `B`: the second object in the pair <br /> |

|                                                                      Returns                                                                      ||
|--------------------------------------------------------------------------------------|-------------------------------------------------------------|
| [Pair](https://developer.android.com/reference/android/support/v4/util/Pair)`<A, B>` | a Pair that is templatized with the types of a and b <br /> |

### equals

```
boolean equals (Object o)
```

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

<br />

|                                                                      Parameters                                                                      ||
|-----|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `o` | `Object`: the[Pair](https://developer.android.com/reference/android/support/v4/util/Pair)to which this one is to be checked for equality <br /> |

|                                        Returns                                         ||
|-----------|-----------------------------------------------------------------------------|
| `boolean` | true if the underlying objects of the Pair are both considered equal <br /> |

### hashCode

```
int hashCode ()
```

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

<br />

|               Returns                ||
|-------|-------------------------------|
| `int` | a hashcode of the Pair <br /> |

### toString

```
String toString ()
```

<br />

<br />

|     Returns      ||
|----------|--------|
| `String` | <br /> |

-

  ## Interfaces

  - [Pools.Pool](https://developer.android.com/reference/android/support/v4/util/Pools.Pool)
-

  ## Classes

  - [ArrayMap](https://developer.android.com/reference/android/support/v4/util/ArrayMap)
  - [ArraySet](https://developer.android.com/reference/android/support/v4/util/ArraySet)
  - [AtomicFile](https://developer.android.com/reference/android/support/v4/util/AtomicFile)
  - [CircularArray](https://developer.android.com/reference/android/support/v4/util/CircularArray)
  - [CircularIntArray](https://developer.android.com/reference/android/support/v4/util/CircularIntArray)
  - [LongSparseArray](https://developer.android.com/reference/android/support/v4/util/LongSparseArray)
  - [LruCache](https://developer.android.com/reference/android/support/v4/util/LruCache)
  - [ObjectsCompat](https://developer.android.com/reference/android/support/v4/util/ObjectsCompat)
  - [Pair](https://developer.android.com/reference/android/support/v4/util/Pair)
  - [PatternsCompat](https://developer.android.com/reference/android/support/v4/util/PatternsCompat)
  - [Pools](https://developer.android.com/reference/android/support/v4/util/Pools)
  - [Pools.SimplePool](https://developer.android.com/reference/android/support/v4/util/Pools.SimplePool)
  - [Pools.SynchronizedPool](https://developer.android.com/reference/android/support/v4/util/Pools.SynchronizedPool)
  - [SimpleArrayMap](https://developer.android.com/reference/android/support/v4/util/SimpleArrayMap)
  - [SparseArrayCompat](https://developer.android.com/reference/android/support/v4/util/SparseArrayCompat)