Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java alternative for C# code [duplicate]

Tags:

java

c#

I have a function with the following declaration in c#. It allows me call the function without providing a value for the expectedDisplayValue variable. The function automatically initializes the variable to "". I want a similar declaration in java. How can I do that?

public bool VerifyControlState(string identifier,string controltype, ButtonProperty buttonProperty, string expectedDisplayValue = "");
like image 913
sakshi goyal Avatar asked Feb 26 '26 00:02

sakshi goyal


1 Answers

The structure of Java handles this through function overloading. Basically, create a function that doesn't have expectedDisplayValue as a parameter and that function would call VerifyControlState (identifier, controltype, buttonProperty, "");

See the Does Java support default parameter values? question for more details.

like image 157
Eddy Avatar answered Feb 28 '26 15:02

Eddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!