我有一个课程abc
,如下所示
public class Abc<T> {
int arg1;
int arg2;
int arg3;
public <T> Abc(int arg1 , int arg2 ,int arg3){
this.arg1 = arg1;
this.arg2 = arg2;
this.arg3 = arg3;
}
public <T> Abc(int arg1, int arg2){
// How to call the above the constructor by setting some value to arg3.
}
}
如何从2参数构造函数中调用3参数?
答案 0 :(得分:2)
像这样:
public <T> Abc(int arg1, int arg2){
this(arg1, arg2, 0);
}
您必须为arg3
定义一个默认值,我使用上面的0
。
注意:我认为您不需要所有<T>