public class Point<T>{
private T x;
private T y;
public T getx()
{
return x;
}
public void setx(T x)
{
this.x=x;
}
public T getY()
{
return y;
}
public void sety(T y)
{
this.y=y;
}
}
public class PointDemo {
//情况1:使用String类型
Point<String> p1=new Point<String>();
String x1=p1.getx();
//情况2:使用Integer类型
Point<Integer>p2=new Point<Integer>();
Integer x2=p2.getx();
}