• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Collections questions

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vidya ,
As for as ur second question is concerned ,
For HashMap infact for any collection, objects can't be used as the key.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vidya,
Hashtable does not allow null value. HashMap can contain a 'null' key and null values. Set can contain atmost one null value.
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lakshmi,
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 ]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks,
Cindy
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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic