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 pass an optional parameter to a class in Python?

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  What does a question mark after a variable mean?

Leave a Reply

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