0

Is there any other way to call constructor, other than new object creation from new operator?

I think when constructor chaining happens in inheritance then also constructor gets called but it does not create parent class object.

T-Heron
  • 5,385
  • 7
  • 26
  • 52
prity
  • 1,519
  • 1
  • 12
  • 17

1 Answers1

0

Yes and no, one way is to have your contructor call some method:

public class SomeClass {
    public SomeClass() {
        init();
    }

    public final void init() {
        // do something
    }
}

Then call init() again later when needed