• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

addAll(? extends E)

 
Ranch Hand
Posts: 47
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know the difference between addAll(? extends E) and add(? super E) notation in Collection interface. I understand the purpose for using 'super' in add(). Why isn't addAll() using 'super' instead of 'extends' for adding elements?
 
Ranch Hand
Posts: 262
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepa Sreedhara wrote:I would like to know the difference between addAll(? extends E) and add(? super E) notation in Collection interface. I understand the purpose for using 'super' in add(). Why isn't addAll() using 'super' instead of 'extends' for adding elements?



I don't think the Collection interface has an add that takes ? super E. The only add and addAll methods I see are the ones listed below.

boolean add(E e)
boolean addAll(Collection<? extends E> c)

Try to understand now why the addAll takes a Collection<? extends E> c?

Edit : Those and the two others that take the index as a parameter also.

 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic