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

Java Equivalent to VB Generics

Java generics and VB generics are implemented in totally different ways - Java generics uses the concept of 'type erasure' (compiling to Object and casts), while VB generics is a run-time feature, but you can usually achieve the same result by converting one to the other.

Defining a Generic Class

VB.NET Java
Public Class GenericClass(Of T)
End Class
public class GenericClass<T>
{
}

Defining a Generic Class with a Constraint

VB.NET Java
Public Class GenericClass(Of T As SomeBase)
End Class
public class GenericClass<T extends SomeBase>
{
}

Defining a Generic Method

VB.NET Java
Public Sub Method(Of T)(ByVal param As T)
End Sub
public <T> void Method(T param)
{
}

Defining a Generic Method with a Constraint

VB.NET Java
Public Sub Method(Of T As SomeBase)(ByVal param As T)
End Sub
public <T extends SomeBase> void Method(T param)
{
}


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

Additional resource: VB.NET and Java Equivalents


Copyright © 2004 – 2019 Tangible Software Solutions, Inc.