public class Pair
extends Object
| java.lang.Object | |
| android.util.Pair<F, S> | |
容器可以轻松地传递两个对象的元组。 这个对象提供了equals()的一个合理的实现,如果equals()对每个包含的对象都为true,则返回true。
Fields |
|
|---|---|
public final F |
first |
public final S |
second |
Public constructors |
|
|---|---|
Pair(F first, S second) 一对的构造函数。 |
|
公共方法(Public methods) |
|
|---|---|
static <A, B> Pair<A, B> |
create(A a, B b) 用于创建适当类型的对的便捷方法。 |
boolean |
equals(Object o) 通过委派他们各自的 |
int |
hashCode() 使用底层对象的哈希代码计算哈希代码 |
String |
toString() 返回对象的字符串表示形式。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
Pair (F first,
S second)
一对的构造函数。
| 参数(Parameters) | |
|---|---|
first |
F: the first object in the Pair |
second |
S: the second object in the pair |
Pair<A, B> create (A a, B b)
用于创建适当类型的对的便捷方法。
| 参数(Parameters) | |
|---|---|
a |
A: the first object in the Pair |
b |
B: the second object in the pair |
| 返回(Returns) | |
|---|---|
Pair<A, B> |
a Pair that is templatized with the types of a and b |
boolean equals (Object o)
通过委派他们各自的 equals(Object)方法来检查两个对象是否相等。
| 参数(Parameters) | |
|---|---|
o |
Object: the Pair to which this one is to be checked for equality |
| 返回(Returns) | |
|---|---|
boolean |
true if the underlying objects of the Pair are both considered equal |
int hashCode ()
使用底层对象的哈希代码计算哈希代码
| 返回(Returns) | |
|---|---|
int |
a hashcode of the Pair |
String toString ()
返回对象的字符串表示形式。 通常, toString方法会返回一个“文本地表示”该对象的字符串。 结果应该是一个简洁但内容丰富的表述,对于一个人来说很容易阅读。 建议所有子类重写此方法。
类Object的toString方法返回一个字符串,其中包含对象为实例的类的名称,符号字符“ @ ”以及对象的哈希代码的无符号十六进制表示形式。 换句话说,这个方法返回一个字符串,其值等于:
getClass().getName() + '@' + Integer.toHexString(hashCode())
| 返回(Returns) | |
|---|---|
String |
a string representation of the object. |