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,"qaz");
System.out.println(p1.getkey()+" "+p1.getvalue());
Pair<String,String> p2=new Pair<>("abc","qaz");
System.out.println(p2.getkey()+" "+p2.getvalue());
}
}
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