Find out the real type in a generic class.
If I have an class that will take an generic type. How can I figure out what is the real type for my instance.
I want to replace the TODO in my example with some code so the example will generate this output:
class java.lang.Integer
class java.lang.Double
My example code:
public class Foo<N extends Number> {
void bar() {
Class c = TODO;
System.out.println("My type is: " + c);
}
public static void main(String[] args) {
new Foo<Integer>().bar();
new Foo<Double>().bar();
}
}

