What is the advantage of constructor over method in Java?

One of the benefits of using a constructor over a method is that you can be assured the constructor was called and the work within the constructor was performed . The language specifies that to construct an object a constructor must be called.

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 *