我的构造函数通常看起来像这样。我还看到很多代码将“基本”构造函数放在最后。我个人喜欢预先看到基础构造函数。在这方面有没有共同的做法?
class foo {
private int _var1;
private long _var2;
private float _var3;
// the "base" constructor
public void foo(int v1, long v2, float v3) {
......
}
public void foo(int v1, long v2) {
this(v1, v2, 0f)
}
public void foo(int v1) {
this(v1, 0L, 0f)
}
}