Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

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:

Public Sub TestOptional(Optional ByVal x As Integer = 0)
    ...
End Sub

Java:

public void TestOptional()
{
    TestOptional(0);
}
public void TestOptional(int x)
{
    ...
}

If you need to convert from VB to Java and you are depending on the results being reliable and accurate, then you will want to have VB to Java Converter, the best VB to Java converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.