Reputation: 1178
I have the next question. I have the code:
public class Foo {
private int x;
public Foo() {
this(1);
}
public Foo(int x) {
this.x = x;
}
}
Can I call from Foo(int x)
Foo()
somehow?
Upvotes: 0
Views: 84
Reputation: 159874
You can't - doing so (calling this()
) would creating a cyclic dependency between the constructors which isnt allowed at compile time
Upvotes: 2