File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Adding elements into generic list doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Adding elements into generic list doubt" Watch "Adding elements into generic list doubt" New topic
Author

Adding elements into generic list doubt

Andry Dub
Ranch Hand

Joined: Nov 06, 2007
Posts: 43
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.



Java is my love
Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131
hi!
for List<? super Number>,you can use add()method,but you can only add those objects which is-a Number.


who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding elements into generic list doubt