All pastes #17553 Raw Edit

Anonymous

public text v1 · immutable
#17553 ·published 2005-07-12 17:25 UTC
rendered paste body
// 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