Is it possible for a constructor to call a constructor within the same class? Not the lower class. What do I do?
java constructor
It's possible!
public class Foo
{
private int x;
public Foo()
{
this(1);
}
public Foo(int x)
{
this.x = x;
}
}
This is how you can call a constructor in the same class Also, the creator of the higher class can use super to call it You can write on the first line of the constructor.
© 2024 OneMinuteCode. All rights reserved.