Originally posted by Tanu Gulati:
That is what i said .......it should accept some thing but apart from null I am not able to pass any parameter to "hello" method.
Okay, you just didn't get it... so, let's try a straight explanation with all levity aside.
"? extends Number" means an *unknown* type that extends the Number class type. The compiler doesn't know what type it is, and at the same time the compile must type check anything that is added.
So, the only way the compiler will let anything to be added is to guarantee that the type being added is the correct type. This isn't possible because the compiler doesn't know what type it is, and there isn't a type that IS-A all the types that extend the number type.
So, it doesn't allow any type of object to be added.
The null is an exception to this. A null can be assigned to any type. Hence, it can be added to the container, no matter what type it is. Hence, it is legal to pass the null.
Henry