This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
java:generics [2015/03/16 06:35] gthanos [Παραμετρικοί τύποι δεδομένων (Generics)] |
java:generics [2015/03/16 07:07] gthanos [Παραμετρικοί τύποι δεδομένων με πολλές παραμέτρους] |
||
---|---|---|---|
Line 86: | Line 86: | ||
public K getKey(); | public K getKey(); | ||
public V getValue(); | public V getValue(); | ||
+ | public void setKey(K key); | ||
+ | public void setValue(V value); | ||
} | } | ||
</code> | </code> | ||
- | + | public class OrderedPair<K, V> implements Pair<K,V> { | |
- | <code java OrderedPair.java> | + | |
- | public class Pair<K, V> { | + | |
private K key; | private K key; | ||
private V value; | private V value; | ||
- | public Pair(K key, V value) { | + | public OrderedPair(K key, V value) { |
this.key = key; | this.key = key; | ||
this.value = value; | this.value = value; | ||
Line 105: | Line 105: | ||
public V getValue() { return value; } | public V getValue() { return value; } | ||
} | } | ||
+ | <code java OrderedPair.java> | ||
</code> | </code> |