[size=large]在static方法中,为什么不能引用类的类型参数?[/size]
[code]
public class Arg< A , B > {
public final A a;
public final B b;
static void setValue(A a,B b){ //This is error. 这里的类型A,B引用的是类中的类型参数。
}
Arg(A a,B b){
this.a=a;
this.b=b;
}
public String toString(){
return "(" + a + "," + b + ")";
}
}
[/code]
[code]
public class Arg< A , B > {
public final A a;
public final B b;
static void setValue(A a,B b){ //This is error. 这里的类型A,B引用的是类中的类型参数。
}
Arg(A a,B b){
this.a=a;
this.b=b;
}
public String toString(){
return "(" + a + "," + b + ")";
}
}
[/code]