aspose file tools*
The moose likes Beginning Java and the fly likes Generic Collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Generic Collection" Watch "Generic Collection" New topic
Author

Generic Collection

anish reddy
Ranch Hand

Joined: Apr 19, 2008
Posts: 74
differnce between List<?> and List<Object>
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838


differnce between List<?> and List<Object>


List<?> can be assigned any kind of object as generic type whereas List<Object> can be assigned only an object of Object class as generic type.
[ September 11, 2008: Message edited by: Vijitha Kumara ]

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Also, List<Object> allows adding any object that IS-A Object (which is every object ). List<?> does not allow adding anything, since the compiler cannot tell if the added object would be compatible with the type - because the type is unknown.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generic Collection