F
- the type of the first object in the pair.S
- the type of the second object in the pair.public final class Pair<F,S>
extends java.lang.Object
Pair
represents a pair of ordered objects.Constructor | Description |
---|---|
Pair(F first,
S second) |
Constructs a
Pair instance representing the specified
ordered pair of objects. |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(java.lang.Object obj) |
Returns
true if the specified object is a
Pair instance representing the same
ordered pair of objects as this , and
returns false otherwise. |
F |
first() |
Returns the first object in the ordered pair of objects.
|
int |
hashCode() |
Returns a hash code value for the object.
|
S |
second() |
Returns the second object in the ordered pair of objects.
|
java.lang.String |
toString() |
Returns a string representation of
this . |
public Pair(F first, S second)
Pair
instance representing the specified
ordered pair of objects.first
- the first object in the ordered pair of objects.second
- the second object in the ordered pair of objects.java.lang.NullPointerException
- if first==null || second==null
.public F first()
public S second()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if the specified object is a
Pair
instance representing the same
ordered pair of objects as this
, and
returns false
otherwise. Two ordered pairs,
p1
and p2
, are equal if
p1.first().equals(p2.first())
&& p1.second().equals(p2.second())
.equals
in class java.lang.Object
obj
- the object to be compared with this
for
equality.true
if the specified object is a
Pair
instance representing the same
ordered pair of objects as this
, and
returns false
otherwise.public java.lang.String toString()
this
. The
exact details of the representation are unspecified and
subject to change.toString
in class java.lang.Object
this
.