Link Details

Link 1040187 thumbnail
User 1176525 avatar

By pengyifan
via programcreek.com
Published: Sep 29 2013 / 06:49

In general, Map is a data structure consisting of a set of key-value pairs, and each key can only appears once in the map. This post summarizes Top 9 FAQ of how to use Java Map and its implemented classes.
  • 13
  • 2
  • 1943
  • 2276

Comments

Add your comment
User 465559 avatar

Oussama SOUABNI replied ago:

0 votes Vote down Vote up Reply

Hashtable doesn't allow null value or null key. Please see the javadoc of put method : This class implements a hashtable, which maps keys to values. Any non-null object can be used as a key or as a value. Or even try it by your self, all the instructions bellow will throw a NullPointerException : hashTable.put(null, ""); hashTable.put("", null); hashTable.put(null, null); The first line in the implementation of function put: // Make sure the value is not null if (value == null) { // line 393 in Hashtable class throw new NullPointerException(); } and line 399 : int hash = key.hashCode(); throws NullPointerException when the key is null.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Play Framework
Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Akka
  2. Design Patterns
  3. OO JS
  4. Cont. Delivery
  5. HTML5 Mobile
  1. Akka
  2. JUnit/EasyMock
  3. Java Performance
  4. REST
  5. Java