Is it possible to add more elements to a collection with bounded generic type

Viewed 292

I tried to declare a set in the following way with bounded generic type:

Set<? extends Number> numbers = new HashSet<Integer>();

Then I tried numbers.add(new Integer(1));, it can not compile. So I would like to know is it possible to add any kind of element to the set I defined? Or doesn't that way of declaration make any sense?

3 Answers
Related