jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections questions" Watch "Collections questions" New topic

Collections questions

Vidya Venkatesh

Joined: Mar 06, 2003
Posts: 12
hi I have some doubts in Collections.
Are there any collections which do not allow null values ?
Can objects of any class be used as the key of a HashMap ?
Chetan M
Ranch Hand

Joined: Dec 18, 2002
Posts: 43
Hi Vidya ,
As for as ur second question is concerned ,
For HashMap infact for any collection, objects can't be used as the key.

No matter how much you know today, you will have to know more tomorrow.<br /> Hakunamatata !!!
Lakshmi Dasari
Ranch Hand

Joined: Mar 03, 2003
Posts: 35
Hi Vidya,
Hashtable does not allow null value. HashMap can contain a 'null' key and null values. Set can contain atmost one null value.

Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Welcome to Javaranch, a friendly place for Java greenhorns.
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with the JavaRanch Naming Policy.
Thanks Pardner!
Hope to see you 'round the Ranch!
[ March 07, 2003: Message edited by: Dan Chisholm ]

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Actually, Chetan M, your name is also not in line with the naming policy.

Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.
Oh Yeah -
List allows duplicates and nulls
Vector allows duplicates and null (sort of - at the end)
Set allows NO duplicates and up to 1 null
But there is no guarantee that someone could not create a Collection that prohibits nulls.
[ March 07, 2003: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://aspose.com/file-tools
subject: Collections questions
It's not a secret anymore!