public class BoundedTypeParamDemo { private A a; public void set(A a) { this.a = a; } public A get() { return a; } public void inspect(U u) { System.out.println("T: " + a.getClass().getName()); System.out.println("U: " + a.getClass().getName()); } public static void main(String[] args) { BoundedTypeParamDemo integerBox = new BoundedTypeParamDemo(); integerBox.set(new Integer(10)); integerBox.inspect(10); // The below will give error integerBox.inspect("some text"); } }