• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generic Collection  RSS feed

 
anish reddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
differnce between List<?> and List<Object>
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Rob Spoor
Sheriff
Posts: 20897
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!