This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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!