Java Generics
public class Parent { public static void main(String[] args){ // generic class constructor Test<Integer> list = new Test<Integer>(); list.setvalue(12); System.out.println(list.getvalue()); } } class Test<T> { // global variable of type T T objvalue; // method setter public void setvalue(T objvalue){ this.objvalue = objvalue; } // method getter public T getvalue(){ return this.objvalue; } } ===================================================== public class Parent { public static void main(String[] args){ // generic class constructor Test<Integer> list = new Test<Integer>(12); System.out.println(list.getvalue()); } } class Test<T> { // global variable of type T T objvalue; // method setter public Test(T objvalue){ this.objvalue = objvalue; } // method getter public T getvalue(){ return this.objvalue; } }