wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes HashMap 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 "HashMap" Watch "HashMap" New topic
Author

HashMap

Ida Achi
Greenhorn

Joined: Oct 02, 2009
Posts: 25

Please explain me the following statement maybe with a code example:

HashMap allows one null key and multiple null values in a collection.


Thank you.
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

Ida Achi wrote:
Please explain me the following statement maybe with a code example:

HashMap allows one null key and multiple null values in a collection.


Thank you.




the above code prints ..
{null=null, 1=null, 2=null, 3=null, 4=null}
Hope this is clear!!!


SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Ida Achi
Greenhorn

Joined: Oct 02, 2009
Posts: 25

Thanks mate. I just get overly confused at times.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The point to remember is that keys in a HashMap must be unique - because of this, there can ofcourse be only one entry in the map which has null as the key.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashMap
 
Similar Threads
How to access Null key value of an HashMap
Hashtable doesn't allow null value and HashMap allows only one null as key
what's the difference between hashtable and hashMap
What is the difference between Hashtable and HashMap classes?
hash map