Back To Java Generics Index
//program to demonstrate generic class with single type parameter //create a generic class with single type parameter class GenericClass
{ private T t; public GenericClass(T t) { this.t = t; } public T get() { return t; } public void set(T t) { this.t = t; } } public class Class1Demo { public static void main(String args[]) { GenericClass
ob=new GenericClass<>(20); System.out.println(ob.get()); } }