//class having Generic Type
class Test<T> {
T ob;
// Constructor
Test(T o) {
ob = o;
}
// method to get value of object of T(Generic Type)
T getOb() {
return ob;
}
// method to print class name and argument type
void show() {
System.out.println("Type of T is : " + ob.getClass().getName());
}
}
// class containing main method
class GenDemo {
// driver method
public static void main(String[] args) {
// creating object of class having Generic type
Test<Integer> t = new Test(10);
// calling show method
t.show();
// calling getOb method
int a = t.getOb();
// printing value of integer passed as argument
System.out.println(a);
// creating object of class having Generic type
Test<String> t1 = new Test("Veera");
// calling show method
t1.show();
// calling getOb method
String str = t1.getOb();
// printing value of string passed as argument
System.out.println(str);
}
}