• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 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) public class GenericClass<T>

Defining a Generic Class with a Constraint

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

Defining a Generic Method

VB.NET Java
Public Sub Method(Of T)(ByVal param As T) 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) 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 © 1997 – 2017 Tangible Software Solutions Inc.