Why do 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.17 Mar 2012

Sizin İçin Seçtik  How do you create an instance of an object in Java?

Leave a Reply

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