Created
March 3, 2017 07:42
-
-
Save saqibmehmoodgit/34fbe72c5afb45e148d7337cae861af1 to your computer and use it in GitHub Desktop.
Genrics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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