java - Differences between HashMap and Hashtable? -


what differences between hashmap , hashtable in java?

which more efficient non-threaded applications?

there several differences between hashmap , hashtable in java:

  1. hashtable synchronized, whereas hashmap not. makes hashmap better non-threaded applications, unsynchronized objects typically perform better synchronized ones.

  2. hashtable not allow null keys or values. hashmap allows 1 null key , number of null values.

  3. one of hashmap's subclasses linkedhashmap, in event you'd want predictable iteration order (which insertion order default), swap out hashmap linkedhashmap. wouldn't easy if using hashtable.

since synchronization not issue you, i'd recommend hashmap. if synchronization becomes issue, may @ concurrenthashmap.


Comments

Popular posts from this blog

java - Null response to php query in android, even though php works properly -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -