Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

meaning of "?" in list

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as we know
List <Integer> list= new ArrayList<Integer>();
can contain only a list of Integers.

then what is the meaning and use of
List <?> list= new ArrayList<Integer>();
what is the use of "?" symbol in this?
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means a list of <<Anything>>. It is called as a wild card. The super class to all Generic collections is not Collection<Object> but a Collection<?>.May be this link could help you understand better.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic