I am trying to create a generic method which accepts a list of numbers in the format below. I know that I should be able to add any class to the list "o" which is at least a number (floats, integers, doubles) BUT also I should be able to add any object because all classes extend from object. In other words, object is a super class of any classs. So I wonder, why do I get an error on the line o.add(p); ?
public int checkType(List<? super Number> o) 
{
   Object p = new Object();
   //error
   o.add(p);
   return - 1;
 }
I followed the explanation of generics from Difference between <? super T> and <? extends T> in Java which is the accepted answer.
 
     
     
    