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()); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter