Simple Casting…1..

simple generic casting…hehe. kayak maen film aja ada casting…qkwkqwk


public class GenX<Y,P> {
 Y Y;
 P P;
 public GenX(Y A,P B){
 this.Y =  A;
 this.P =  B;
 }
 public Y getY(){
 return (Y) Y;
 }
 public P getP(){
 return (P) P;
 }
}


public class GenXPlay {
 public static void main(String[] args){
 GenX<String,Integer> mira = new GenX<String,Integer>("yaniar" , 22);
 String test = mira.getY();
 int test2 = mira.getP();
 System.out.print(test + " " + test2 + "\n");
 }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s