Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Collection Interface addAll() method signature

What difference would it make if Java Collection Interface has addAll method signature like this

 <T extends E> boolean addAll(Collection<T> c);

rather than boolean addAll(Collection<? extends E> c);?

Thanks

-Abidi

like image 861
Abidi Avatar asked Mar 09 '26 04:03

Abidi


1 Answers

In this case, having <?> or <T> is equivalent for users of addAll.

I think that the former notation was used for clarity, because using <T> makes the signature of addAll more complicated.

like image 93
frm Avatar answered Mar 11 '26 16:03

frm