Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding elements into generic list doubt  RSS feed

 
Andry Dub
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, dear ranchers! I am very confused. Why I can add Integer or Short into list, that must contain only parants of Number. And I cannot insert Object while Object is superclass of Number.

 
Fu Dong Jia
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
for List<? super Number>,you can use add()method,but you can only add those objects which is-a Number.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!