See More

/*------------------------------------------------------------------------------ * Oracle Certified Professional Java SE 8 Programmer Exam 1Z0-809 * A Comprehensive OCPJP 8 Certification Guide * by SG Ganesh, Hari Kiran and Tushar Sharma ------------------------------------------------------------------------------*/ // This program shows container implementation using generics class BoxPrinter { private T val; public BoxPrinter(T arg) { val = arg; } public String toString() { return "[" + val + "]"; } } class BoxPrinterTest { public static void main(String []args) { BoxPrinter value1 = new BoxPrinter(new Integer(10)); System.out.println(value1); BoxPrinter value2 = new BoxPrinter("Hello world"); System.out.println(value2); } }