You could look into sources of JDK to learn this... HashMap maintains an array of Entry items and it allows one only item  with the key to be null. Also there are two private methods -- putForNullKey & getForNullKey. Both perform search over the entire table of entries so the get/insert operations have linear complexity relatively to the size of that array


The question about scenarios of null keys usage in HashMap has been already discussed in this mailing list & one of the answers was to provide a default value for something; please perform a search to get more information on this


Saturday, October 30, 2010, 5:36:00 PM, you wrote:


>

Hi All,


HashMap allows one key as null but Hashtable does not allow any of the keys to be null.


Now if HashMap allows a one key to be null then "Which bucket does a null key map to?"


Also please tell me in which scenarios one would like to place a null key in HashMap?



Thanks,


-Nirmal


                 \\\///

              /         \

              | \\   // |

            ( | (.) (.) |)

----------o00o--(_)--o00o-------------------

Stand up,be bold,be strong.

Take the whole responsibility on

ur own shoulders and know that

U are the creator of ur own destiny

------ooo0-------------------------------------

    (   )     0ooo  

     \ (      (   )

      \_)      ) /

              (_/     

-- 

You received this message because you are subscribed to the Google

Groups "Java EE (J2EE) Programming with Passion!" group.

To post to this group, send email to

java-ee-j2ee-programming-with-passion@googlegroups.com

To unsubscribe from this group, send email to

java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com

For more options, visit this group at

http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en 





-- 

Best regards,

 Aleksei                            mailto:aleksey.mesh...@tut.by

--
You received this message because you are subscribed to the Google
Groups "Java EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en

Reply via email to