Unable to understand the use of Java templates?
Suppose I have the following piece of code
Number n=new Integer(2);
then when i use the code it shows an error
Class<Number> hi=n.getClass(); //type mismatch error
but if the code below works fine
Class<? extends Number> hi=n.getClass();
Why is that? Please explain in a few simple and precise words.
+3
user3768208
source
to share