Generic Constructor
public class GenericConstructor<E> {
E value;
public GenericConstructor(E item) { /*generic constructor*/
value=item;
System.out.println(value);
}
public static void main(String[] args) {
System.out.println("String value:");
GenericConstructor gc1=new GenericConstructor("Hello World..!!");
System.out.println("Integer value:");
GenericConstructor gc2=new GenericConstructor(100);
}
}
Output:
String value:
Hello World..!!
Integer value:
100