Stay organized with collections
Save and categorize content based on your preferences.
Pair
open class Pair<F : Any!, S : Any!>
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 |
Pair(first: F, second: S)
Constructor for a Pair.
|
Public methods |
open static Pair<A, B>! |
Convenience method for creating an appropriately typed pair.
|
open Boolean |
Checks the two objects for equality by delegating to their respective Object.equals(Object) methods.
|
open Int |
Compute a hash code using the hash codes of the underlying objects
|
open String |
|
Public constructors
Pair
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 methods
create
open static fun <A : Any!, B : Any!> 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 |
Return |
Pair<A, B>! |
a Pair that is templatized with the types of a and b |
equals
open fun equals(other: Any?): Boolean
Checks the two objects for equality by delegating to their respective Object.equals(Object)
methods.
Parameters |
obj |
the reference object with which to compare. |
o |
the Pair to which this one is to be checked for equality This value may be null . |
Return |
Boolean |
true if the underlying objects of the Pair are both considered equal |
hashCode
open fun hashCode(): Int
Compute a hash code using the hash codes of the underlying objects
Return |
Int |
a hashcode of the Pair |
toString
open fun toString(): String
Return |
String |
a string representation of the object. |
Properties
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Pair\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nPair\n====\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/util/Pair \"View this page in Java\") \n\n```\nopen class Pair\u003cF : Any!, S : Any!\u003e\n```\n\n|---|------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.util.Pair](#) |\n\nContainer 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.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------------------------------------------------------------------------|---|\n| [Pair](#Pair(android.util.Pair.F,%20android.util.Pair.S))`(`first:` `F`, `second:` `S`)` Constructor for a Pair. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [Pair](#)\\\u003cA, B\\\u003e! | [create](#create(android.util.Pair.create.A,%20android.util.Pair.create.B))`(`a:` `A`, `b:` `B`)` Convenience method for creating an appropriately typed pair. |\n| open [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` Checks the two objects for equality by delegating to their respective [Object.equals(Object)](../../java/lang/Object.html#equals(kotlin.Any)) methods. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](#hashCode())`()` Compute a hash code using the hash codes of the underlying objects |\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](#toString())`()` \u003cbr /\u003e |\n\n| Properties ||\n|---|----------------------------------------------|\n| F | [first](#first:android.util.Pair.F) \u003cbr /\u003e |\n| S | [second](#second:android.util.Pair.S) \u003cbr /\u003e |\n\nPublic constructors\n-------------------\n\n### Pair\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nPair(\n first: F, \n second: S)\n```\n\nConstructor for a Pair.\n\n| Parameters ||\n|----------|----------------------------------|\n| `first` | F: the first object in the Pair |\n| `second` | S: the second object in the pair |\n\nPublic methods\n--------------\n\n### create\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun \u003cA : Any!, B : Any!\u003e create(\n a: A, \n b: B\n): Pair\u003cA, B\u003e!\n```\n\nConvenience method for creating an appropriately typed pair.\n\n| Parameters ||\n|-----|----------------------------------|\n| `a` | A: the first object in the Pair |\n| `b` | B: the second object in the pair |\n\n| Return ||\n|--------------------|------------------------------------------------------|\n| [Pair](#)\u003cA,` `B\u003e! | a Pair that is templatized with the types of a and b |\n\n### equals\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun equals(other: Any?): Boolean\n```\n\nChecks the two objects for equality by delegating to their respective [Object.equals(Object)](../../java/lang/Object.html#equals(kotlin.Any)) methods.\n\n| Parameters ||\n|-------|-----------------------------------------------------------------------------------------|\n| `obj` | the reference object with which to compare. |\n| `o` | the [Pair](#) to which this one is to be checked for equality This value may be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if the underlying objects of the Pair are both considered equal |\n\n### hashCode\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun hashCode(): Int\n```\n\nCompute a hash code using the hash codes of the underlying objects\n\n| Return ||\n|----------------------------------------------------------------------------|------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a hashcode of the Pair |\n\n### toString\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun toString(): String\n```\n\n| Return ||\n|----------------------------------------------------------------------------------|----------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |\n\nProperties\n----------\n\n### first\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval first: F\n``` \n\n### second\n\nAdded in [API level 5](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nval second: S\n```"]]