• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding elements into generic list doubt

 
Andry Dub
Ranch Hand
Posts: 43
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic