This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes null values of 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 "null values of collections" Watch "null values of collections" New topic
Author

null values of collections

natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
Can anyone say how many null values are allowed in the following collections:
(1) ArrayList
(2) TreeMap
(3) LinkedList
(4) HashSet
(5) HashMap
I know hashtable does not allow any null values. The API does not clearly say this. It just says ArrayList, etc. allow values including null.
TIA.

Sun Certified Programmer for Java 2 Platform
Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
(1) ArrayList
(2) TreeMap
(3) LinkedList
(4) HashSet
(5) HashMap
All of them allow null values. Try it. The only thing is in a set values must be unique. SO if you add another null the value will not be added or it will be removed and a new null value be added i don't remember.


Val SCJP <BR>going for SCJD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: null values of collections