Why do addAll and removeAll methods contain different signature as highlighted below. Same thing with add and remove.
boolean addAll(Collection<? extends E> c)
boolean removeAll(Collection<?> c)
boolean add(E e)
boolean remove(Object o)
When we cant add other than the elements of type E or those which extends E, then why should we have removeAll/remove generified?
EX:
List<Number> numbers = new ArrayList<Number>();
numbers.add(123);
numbers.add("hello");
numbers.remove("hello");
in the code above why line3 will give you the compiler error but not line 4. Please explain.