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

Java Equivalent to C# Generics

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

Defining a Generic Class

C# Java
public class GenericClass<T> public class GenericClass<T>

Defining a Generic Class with a Constraint

C# Java
public class GenericClass<T> where T: SomeBase public class GenericClass<T extends SomeBase>

Defining a Generic Method

C# Java
public void Method<T>(T param) public <T> void Method(T param)

Defining a Generic Method with a Constraint

C# Java
public void Method<T>(T param) where T: SomeBase public <T extends SomeBase> void Method(T param)


Use C# to Java Converter to convert from C# to Java.     

Additional resource: Java and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.