wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
 
subject: Adding elements into generic list doubt
 
Similar Threads
generics code mixed with legacy collection
Manipulations with array list.
one more doubt abt generics
generic question
Problem with Generics