Why we use constructor instead of methods?

The most important difference: When you instantiate an object it’s constructor will be invoked whereas calling a method is always optional . You therefore might forget to call your initialization method and fail to initialize everything correctly.

Sizin İçin Seçtik  Why do we use constructors in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *