public class Container { private Object obj; public Container(Object obj) { this.obj = obj; } public Object getObj() { return this.obj; } public void showType() { System.out.println("Type is: " + obj.getClass().getName()); } public static void main(String[] args) { // Container for a String Container c1 = new Container("Generics"); String s = (String) c1.getObj(); System.out.println("String is: " + s); c1.showType(); // Container for an Integer Container c2 = new Container(123); int i = (Integer) c2.getObj(); System.out.println("Integer is: " + i); c2.showType(); } }