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

VB Equivalent to Java 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

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

Defining a Generic Class with a Constraint

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

Defining a Generic Method

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

Defining a Generic Method with a Constraint

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


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

Additional resource: VB.NET and Java Equivalents


Copyright © 2004 – 2019 Tangible Software Solutions, Inc.