constructor使用参数化构造函数时是否需要声明默认值?
我们可以创建它的参数化对象class,并且该对象可以用来调用该类的其他函数,那么为什么我们需要默认构造函数呢?
public class Const {
Const(int s,int t) {
int b=s+t;
System.out.println(b);
}
public int add(int a) {
int j = 9;
j=j+a;
return j;
}
}
public class Construct {
public static void main(String[] args) {
Const obj =new Const(5,9);
obj.add(55);
}
}
这里我们不需要默认构造函数。我们可以不去这个对象吗?
 偶然的你
偶然的你 
					森林海
 
					回首忆惘然
 
					慕工程0101907
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类