• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

Java Equivalent to VB Optional Parameters

Java does not allow optional parameters.  Overloaded methods are the only alternative in Java to optional parameters (these are inserted into the converted code by VB to Java Converter).  A VB method with n optional parameters is converted to n + 1 overloaded methods.  The overloaded methods call the overloaded method with the maximum number of parameters (which contains your original method code), passing the default values originally specified for the original optional parameters.

Here's an example of the simplest possible case:

VB Java
Public Sub TestOptional(Optional ByVal x As Integer = 0)
    ...
End Sub
public void TestOptional()
{
    TestOptional(0);
}
public void TestOptional(int x)
{
    ...
}


Use VB to Java Converter to convert from VB to Java.     


Copyright © 1997 – 2017 Tangible Software Solutions Inc.