|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object util.Pair<A,B>
A
- The type of the first element of a pair.B
- The type of the second element of a pair.public class Pair<A,B>
A pair of objects of some specified type. Convenient for return values, etc.
Field Summary | |
---|---|
A |
a
The first element of the pair. |
B |
b
The second element of the pair. |
Constructor Summary | |
---|---|
Pair(A a,
B b)
|
Method Summary | ||
---|---|---|
boolean |
equals(Object other)
|
|
int |
hashCode()
|
|
static
|
of(A a,
B b)
A more readable synonym for pair(A, B) . |
|
static
|
pair(A a,
B b)
A convenience method so that the types of the elements don't have to be given explicitly. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final A a
public final B b
Constructor Detail |
---|
public Pair(A a, B b)
a
- The first element of the pair.b
- The second element of the pair.Method Detail |
---|
public static <A,B> Pair<A,B> pair(A a, B b)
Without this method, this would be required to create a Pair:
Pair<Integer, String> stuff = new Pair<Integer, String>(42, "spam");
With this method:
Pair<Integer, String> stuff = Pair.pair(42, "spam");
A
- The type of the first element.B
- The type of the second element.a
- The first element of the pair.b
- The second element of the pair.
public static <A,B> Pair<A,B> of(A a, B b)
pair(A, B)
.
A
- The type of the first element.B
- The type of the second element.a
- The first element of the pair.b
- The second element of the pair.
public boolean equals(Object other)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |