What is optional parameter in Java?

There are no optional parameters in Java . What you can do is overloading the functions and then passing default values. void SomeMethod(int age, String name) { // } // Overload void SomeMethod(int age) { SomeMethod(age, “John Doe”); }

Sizin İçin Seçtik  Is cryptocurrency safer than traditional currency?

Leave a Reply

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

What is optional parameter in Java?

There are no optional parameters in Java . What you can do is overloading the functions and then passing default values. void SomeMethod(int age, String name) { // } // Overload void SomeMethod(int age) { SomeMethod(age, “John Doe”); }

Sizin İçin Seçtik  How do you make a parameter optional in C#?

Leave a Reply

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