public class Pair<K, V> { private K key; private V val; public Pair(K key, V val) { this.key = key; this.val = val; } public K getKey() { return this.key; } public V getVal() { return this.val; } public static void main(String[] args) { Pair<Integer, String> p1 = new Pair<>(123, "abc"); Integer i = p1.getKey(); System.out.println(i); System.out.println(p1.getVal()); } }