*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections" Watch "Collections" New topic
Author

Collections

Mahesh Bansal
Ranch Hand

Joined: Nov 28, 2000
Posts: 82
Which of the collection classes can contain null items and under what conditions.
Can someone please explain.
Thanks
Mahesh
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
All collection collections can have null items. Including sets (but only one allowed). This means others can have more than one.
Maps can have one key as null, and multiple values as null.
I am little bit doubtful. Can anyone confirm me please?
thanks,
Natarajan

Sun Certified Programmer for Java 2 Platform
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Set can have no dups and at most 1 null.
List can have dups and many nulls.
Maps can have no dup keys (but can have dup elements) and SOME maps allow nulls
HashMap allows nulls
TreeMap allow nulls EXCEPT those that use natural ordering.
HashTable does NOT allow nulls.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
wood burning stoves
 
subject: Collections
 
Similar Threads
Can the color for the disabled item be changed
WA #1.....word association
Private methods
URGENT - NEED HELP - Block Code
error in Marcus Green 2.