K
- Key type.V
- Value type.public class Pair<K,V> extends Object
Although the instances of this class are immutable, it is impossible to ensure that the references passed to the constructor will not be modified by the caller.
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(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.
|
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(Object o)
public int hashCode()
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
.Copyright © 2016 Hipparchus.org. All rights reserved.