• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 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()
public void TestOptional(int x)

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

Additional resource: VB.NET and Java Equivalents

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.