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 = "");
Answer
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.
No comments:
Post a Comment