K
- Key type.V
- Value type.public class Pair<K,V>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private K |
key
Key.
|
private V |
value
Value.
|
Constructor and Description |
---|
Pair(K k,
V v)
Create an entry representing a mapping from the specified key to the
specified value.
|
Pair(Pair<? extends K,? extends V> entry)
Create an entry representing the same mapping as the specified entry.
|
Modifier and Type | Method and Description |
---|---|
static <K,V> Pair<K,V> |
create(K k,
V v)
Convenience factory method that calls the
constructor . |
boolean |
equals(java.lang.Object o)
Compare the specified object with this entry for equality.
|
K |
getFirst()
Get the first element of the pair.
|
K |
getKey()
Get the key.
|
V |
getSecond()
Get the second element of the pair.
|
V |
getValue()
Get the value.
|
int |
hashCode()
Compute a hash code.
|
java.lang.String |
toString() |
public Pair(K k, V v)
k
- Key (first element of the pair).v
- Value (second element of the pair).public K getKey()
public V getValue()
public K getFirst()
public V getSecond()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Object.true
if the given object is also a map entry and
the two entries represent the same mapping.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static <K,V> Pair<K,V> create(K k, V v)
constructor
.K
- the key typeV
- the value typek
- First element of the pair.v
- Second element of the pair.Pair
containing k
and v
.