• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

Java Equivalent to VB Extension Methods

Java doesn't have extension methods, so a VB extension method is just converted to an ordinary Java static method (calls to the method have to be adjusted to static calls using the class name).

VB Java
Public Module ContainsExtension
    <System.Runtime.CompilerServices.Extension> _
    Public Sub ExtensionMethod(ByVal myParam As String)
    End Sub
End Module
Friend Class TestClass
    Private Sub TestMethod()
        Dim s As String
    End Sub
End Class
public final class ContainsExtension
    public static void ExtensionMethod(String myParam)
public class TestClass
    private void TestMethod()
        String s = null;

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.