I think allowing recursion can be very handy sometimes, not because I can code in “recursion” but rather because I can save some code space for some cases like below
public class SomeClass
{
private int a;
SomeClass(int a)
{
this.a = a;
}
SomeClass()
{
SomeClass(3);
}
}
This is especially effective when one constructor tries to take advantage of another that contains big chunks of code.
However, Java clearly doesn’t support this feature, and I believe it doesn’t for a very good reason. Could anyone care to explain why though?
Java does support this, but you need to use different syntax: