Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saqibmehmoodgit/34fbe72c5afb45e148d7337cae861af1 to your computer and use it in GitHub Desktop.
Save saqibmehmoodgit/34fbe72c5afb45e148d7337cae861af1 to your computer and use it in GitHub Desktop.
Genrics
public class PairMultiParamter<K,V>
{
K key;
V val;
public PairMultiParamter(K key, V val) {
super();
this.key = key;
this.val = val;
}
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getVal() {
return val;
}
public void setVal(V val) {
this.val = val;
}
////
public class Country
{
String name ;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Country [name=" + name + "]";
}
}
///////////////
main method of run class
Country country = new Country();
country.setName("Pakistan");
PairMultiParamter<Integer ,Country> pMV = new PairMultiParamter<Integer, Country>(1, country);
pMV.getKey();
Country cont = pMV.getVal();
System.out.println(" Kay : " + pMV.getKey() + " Value is "+ pMV.getVal().getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment