0
$\begingroup$

I have checked many websites but did not get the right answer. what is the meaning of constructor in java?

$\endgroup$

closed as off-topic by Yuval Filmus, Evil, dkaeae, chi, David Richerby May 28 at 15:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development or programming tools are off-topic here, but can be asked on Stack Overflow." – Yuval Filmus, Evil, dkaeae, chi, David Richerby
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Java questions are off-topic here. You can likely find the answer in a Java textbook. $\endgroup$ – Yuval Filmus May 28 at 14:55
0
$\begingroup$

Constructors are used to initialize the object’s state. Like methods of, a constructor also contains collection of statements(i.e. instructions) that are executed at time of Object creation.A constructor is invoked at the time of object or instance creation. 

$\endgroup$
  • 2
    $\begingroup$ This question is clearly off-topic for this site. Instead of answering here, flag the question as off-topic and/or request a mod to migrate to Stack Overflow. You can also inform the question asker that this is off-topic here (and where the question should go!). Feel free to answer the question after it has migrated/moved to the appropriate site $\endgroup$ – dkaeae May 28 at 15:20
  • $\begingroup$ @dkaeae Brand-new users aren't going to have a good idea of what's on-topic (though Yuval's comment on the question was posted several minutes before this answer). Note that users with less than 15 rep can't flag, and users with less than 50 rep can't comment. $\endgroup$ – David Richerby May 28 at 15:50
  • $\begingroup$ Okay i am new here so I'll keep this in mind while answer the next question $\endgroup$ – Saba N May 28 at 16:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.