This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

Vector and null

 
Sarma Lolla
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following types can be added to java.util.Vector?
A) reference
B) null
C) int
D) All of the above
The answer given in the mock are A, B.
When I verified I am able to add null to Vector.
Are there any other collection classes where I can add null?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the Collection classes can hold nulls. By the way, the JavaRanch newsletter has a multi-part article on Collections.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sarma. Hashtable won't allow null for keys or values. While HashMap allows the null key and null values.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic