Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I doubt the differences can be explained significantly better than what's already written in the JavaDocs for these classes:</p> <ul> <li><a href="http://download.oracle.com/javase/6/docs/api/java/util/Map.html" rel="noreferrer">Map</a> is the basic interface common to all these classes</li> <li>a <a href="http://download.oracle.com/javase/6/docs/api/java/util/Hashtable.html" rel="noreferrer">Hashtable</a> is one implementation of that interface, for the "old" days when it was thought that having everything synchronized is a good idea (ref. <a href="http://download.oracle.com/javase/6/docs/api/java/util/Vector.html" rel="noreferrer">Vector</a>). It offers "kind of" thread-safety, if you know what you are doing. If you are serious about a map which can be used from multiple threads you should absolutely check out the <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="noreferrer"><code>ConcurrentHashMap</code></a> and <a href="http://download.oracle.com/javase/6/docs/api/java/util/concurrent/ConcurrentSkipListMap.html" rel="noreferrer"><code>ConcurrentSkipListMap</code></a>.</li> <li>a <a href="http://download.oracle.com/javase/6/docs/api/java/util/HashMap.html" rel="noreferrer">HashMap</a> is almost the same as a Hashtable, but with the synchronization removed. It's the preferred general-purpose Map implementation.</li> <li>a <a href="http://download.oracle.com/javase/6/docs/api/java/util/LinkedHashMap.html" rel="noreferrer">LinkedHashMap</a> additionally maintains a linked list of it's entries, which allows to maintain an ordering or use it as a LRU cache easily, just read the JavaDoc.</li> </ul> <p>All of the aforementioned <code>Map</code> implementations have their basic get/put operations in (amortized) <em>O(1)</em> time complexity. There are minor differences in the handling of <code>null</code> values, it's inevitable to check the JavaDoc for details.</p> <p>To get an idea of how these classes are implemeted, have a look at their inheritance tree:</p> <ul> <li><code>Map</code> (just the interface) <ul> <li><code>Dictionary</code> (obsoleted abstract class) <ul> <li><code>Hashtable</code> (the "old" map implementation lives on it's own)</li> </ul></li> <li><code>AbstractMap</code> (the basic functionality of the "new" map implementations) <ul> <li><code>HashMap</code> (the first concrete map implementation for general purpose use) <ul> <li><code>LinkedHashMap</code> (extends <code>HashMap</code> by mainaining the linked list)</li> </ul></li> </ul></li> </ul></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload