-5

In what situation we implement the explicit constructors in java program and when we doesn't need to implement explicit constructors.

  • 1
    welcome to SO. Please read http://stackoverflow.com/help/mcve – pcantalupo Sep 11 '15 at 13:46
  • 1
    Please put an example, what do you think this behaviour should be and the behaviour that you have seen. – Francisco Romero Sep 11 '15 at 13:51
  • 1
    In regards - typically SO is not for "please give me code". Also similar questions have already been answered, please see http://stackoverflow.com/questions/10265311/what-is-implicit-constructors-on-java – Sh4d0wsPlyr Sep 11 '15 at 13:53
  • You need to implement explicit constructors when you need to use them. – Manu Sep 11 '15 at 14:03

1 Answers1

0

This article explains the full story. In short: you need explicit constructors if you want to pass parameters to this constructor. If you do not need this, you can either provide a "parameterless" constructor ( public Foo() {} ), or you do nothing, in which case the system will create an empty one for you in the background.

Gergely Bacso
  • 14,243
  • 2
  • 44
  • 64