1. 程式人生 > >使用多個泛型demo

使用多個泛型demo

poi etx this private ati blog xiang [] gef

package duogefanxing.cn;
/*
 * 使用多個泛型
 */
class Point <t,v> {
private t x;
private v y;
public void setx(t  x){
    this.x = x;
}
public t getx(){
    return x;
}
public void sety(v  y){
    this.y = y;
}
public v gety(){
    return y;
}
}
public class FanXingDemo3 {
public static void main(String[] args) {
            Point 
<Integer,String>p = new Point<Integer,String>(); p.sety("xixianghua"); p.setx(78); System.out.println(p.getx()); System.out.println(p.gety()); } }

使用多個泛型demo