This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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
 
Don't get me started about those stupid light bulbs.
 
subject: null values of collections
 
Similar Threads
Difference between arraylist.clear(); arralist=null
Why does HashMap allow 'null' values
100% in SCJP 5.0
HashSet question
Collections questions