• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generic Collection

 
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
Pie
Posts: 3918
10
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
Pie
Posts: 20661
65
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