aspose file tools*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections