This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • 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
Saloon Keeper
Posts: 3997
42
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: 21090
85
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!