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

Java Equivalent to VB Local Static Variables

The closest equivalent to VB's local Static variable is a private field.  If (and only if) the local static variable was declared in a Shared method, then the Java field should be declared as static.  VB to Java Converter creates new fields for each local Static variable found.  The field name is prefixed by the method name to ensure uniqueness.

VB Java
Public Class StaticLocals
    Public Sub MethodOne()
        Static i As Integer
        ...
        j = i
    End Sub

    Public Shared Sub MethodTwo()
        Static i As Integer
        ...
        j = i
    End Sub
End Class
public class StaticLocals
{
    private int MethodOne_i;
    private static int MethodTwo_i;

    public final void MethodOne()
    {
        //...
        j = MethodOne_i;
    }

    public static void MethodTwo()
    {
        //...
        j = MethodTwo_i;
    }
}


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

Additional resource: VB.NET and Java Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.