how to call a constructor from another constructor in java
Use this keyword to achieve this
public class FooConstructor
{
private int x;
public FooConstructor ()
{
this(1);
}
public FooConstructor (int x)
{
this.x = x;
}
}
Use this keyword to achieve this
public class FooConstructor
{
private int x;
public FooConstructor ()
{
this(1);
}
public FooConstructor (int x)
{
this.x = x;
}
}