Advertisement
Vermiculus

Untitled

Nov 1st, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1.  
  2. public class KeyValuePair<K extends Comparable<K>, V> implements Comparable<KeyValuePair<K, V>> {
  3.     public KeyValuePair(K key, V value) {
  4.         super();
  5.         this.key = key;
  6.         this.value = value;
  7.     }
  8.  
  9.     private K key;
  10.     private V value;
  11.    
  12.    
  13.     public V getValue() {
  14.         return value;
  15.     }
  16.  
  17.     public void setValue(V value) {
  18.         this.value = value;
  19.     }
  20.  
  21.     public K getKey() {
  22.         return key;
  23.     }
  24.  
  25.     @Override
  26.     public String toString() {
  27.         return "KeyValuePair [key=" + key + ", value=" + value + "]";
  28.     }
  29.  
  30.     @Override
  31.     public int compareTo(KeyValuePair<K, V> o) {
  32.         return key.compareTo(o.getKey());
  33.     }
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement