java call constructor in constructor code example
Example 1: java call another constructor
public class Foo {
private int x;
public Foo() {
this(1);
}
public Foo(int x) {
this.x = x;
}
}
Example 2: calling this in constructor java
In Java another constructor of the same class can be called from a
constructor via this().
Note however that this has to be on the first line.