Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
Pair
public
final
class
Pair
extends Object
| java.lang.Object
|
| ↳ |
com.android.utils.Pair<S, T>
|
A Pair class is simply a 2-tuple for use in this package. We might want to think about adding
something like this to a more central utility place, or replace it by a common tuple class if one
exists, or even rewrite the layout classes using this Pair by a more dedicated data structure (so
we don't have to pass around generic signatures as is currently done, though at least the
construction is helped a bit by the of(S, T) factory method.
Summary
Public methods |
boolean
|
equals(Object obj)
|
S
|
getFirst()
Return the first item in the pair
|
T
|
getSecond()
Return the second item in the pair
|
int
|
hashCode()
|
static
<S, T>
Pair<S, T>
|
of(S first, T second)
Constructs a new pair of the given two objects, inferring generic types.
|
String
|
toString()
|
Public methods
equals
public boolean equals (Object obj)
getFirst
public S getFirst ()
Return the first item in the pair
| Returns |
S |
the first item in the pair |
getSecond
public T getSecond ()
Return the second item in the pair
| Returns |
T |
the second item in the pair |
hashCode
public int hashCode ()
of
public static Pair<S, T> of (S first,
T second)
Constructs a new pair of the given two objects, inferring generic types.
| Parameters |
first |
S: the first item to store in the pair |
second |
T: the second item to store in the pair |
| Returns |
Pair<S, T> |
a new pair wrapping the two items |
toString
public String toString ()
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-12-04 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-12-04 UTC."],[],[]]