public class Pair<K, V> { private K key; private V value; public Pair(K key, V value) { this.key = key; this.value = value; } public K getKey() { return this.key; } public V getValue() { return this.value; } public static void main(String[] args) { Pair<Integer, String> p1 = new Pair<>(123, "Generics"); Integer key = p1.getKey(); String value = p1.getValue(); System.out.println("Key: " + key); System.out.println("Value: " + value); } }