// MyGenericType.java
public class MyGenericType<T> {
public MyGenericType(final T value) {
this.value = value;
}
public T GetValue() {
return value;
}
public void SetValue(final T value) {
this.value = value;
}
private T value;
}
// TestGenericType.java
public class GenericTypeTest {
public static void main(String[] args) {
MyGenericType<Integer> aGenericInstance = new MyGenericType<Integer>(1);
MyGenericType<MyGenericType<Integer>> anotherGenericInstance = new MyGenericType<MyGenericType<Integer>>(aGenericInstance);
System.out.println(aGenericInstance.getClass().getName());
System.out.println(anotherGenericInstance.getClass().getName());
}
}
// Salida
[abarto@viper java]$ java GenericTypeTest
MyGenericType
MyGenericType