I want to call default constructor from a parameterized constructor inside a public java class.
Can I achieve it?
In Java, the default constructor is the no-argument constructor that's implicitly provided by the compiler. And the compiler won't provide one in case you introduce any constructor with arguments.
In that case you have to explicitly define a no-argument constructor (which is not default by the way, because it's not provided by the compiler), e.g. public MyClass() { }
.
And you can call it from other constructor as this();
, which must be the first statement in the constructor where it's being called.