有高手知道泛型类该怎么使用么?
以下的错是因为什么缘故?
public interface Compute<T> {//创建Compute接口
abstract void add();//创建抽象方法加减乘除四个对象
abstract void substract();
abstract void mulitiply();
abstract void divide();
}
-------------
public class Computer<N, T> implements Compute<T>{//定义泛型类Compute
public N X;
public N Y;
public Computer(){
}
public Computer(N x,N y){
X=x;
Y=y;
}@Override
public void add() {
// TODO Auto-generated method stub
System.out.println(X+"+"+Y+"="+(X+Y));
}
@Override
public void substract() {
// TODO Auto-generated method stub
System.out.println(X+"-"+Y+"="+(X-Y));
}
@Override
public void mulitiply() {
// TODO Auto-generated method stub
System.out.println(X+"/"+Y+"="+X/Y);
}
@Override
public void divide() {
// TODO Auto-generated method stub
System.out.println(X+"*"+Y+"="+X*Y);
}
public N getX() {
return X;
}
public void setX(N x) {
X = x;
}
public N getY(){
return Y;
}
public void setY(N y){
Y=y;
}
}
------